Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cext/manifest.c @ 37873:d9e87566f879 stable
cext: stop worrying and love the free(NULL)
There is no need to check for a NULL pointer before calling free since
free(NULL) is defined by C standards as a no-op. Lots of software relies on
this behavior so it is completely safe to call even on the most obscure of
systems.
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Wed, 13 Jun 2018 10:37:39 -0400 |
parents | 1f8c3fadbb8e |
children | 6caca2a7d37f |
line wrap: on
line diff
--- a/mercurial/cext/manifest.c Sun May 20 23:05:18 2018 -0400 +++ b/mercurial/cext/manifest.c Wed Jun 13 10:37:39 2018 -0400 @@ -190,10 +190,8 @@ free(self->lines[i].start); } } - if (self->lines) { - free(self->lines); - self->lines = NULL; - } + free(self->lines); + self->lines = NULL; if (self->pydata) { Py_DECREF(self->pydata); self->pydata = NULL;