small simplification to DLIST_REMOVE

Michael Adam obnox at samba.org
Wed Aug 26 08:58:08 MDT 2009


Hi Jeremy, list,

current DLIST_REMOVE(list, p) code looks like this:

if ((list) == (p)) {
	(list) = (list)->next;
	if ((list)) {
		(list)->prev = NULL;
	}
} else {
	...
}
if ((list) != (p)) {
	(p)->next = (p)->prev = NULL;
}

Jeremy, in the logs I found that you introduced the last check
"if ((list) != (p))" with the comment that it fixes
a memory leak when DLIST_REMOVE(head, head) is called
(e.g. from lib/interface.c).
(See commit 4fd8afaf573054eaa838398f62918757659c2c21 in v3-2-test).

But I don't quite understand that.
I think that there is no memory leak and that the check should
be removed. See the commit message of the attached patch
(agains master) for explanation and analysis.
Am I missing something here?

Cheers - Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-util-remove-superfluous-check-in-DLIST_REMOVE.patch
Type: text/x-patch
Size: 1656 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20090826/befdee9f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 206 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20090826/befdee9f/attachment.pgp>


More information about the samba-technical mailing list