Quoting Christian Biere <[EMAIL PROTECTED]> from ml.softs.gtk-gnutella.devel:
:Then what is the purpose of checking 'lid'? It seems pmi->nl can actually
:be a dangling pointer and this is the point of the check. The code could
:be made standard compliant by using pmi->lid instead of pmi->nl because
:'lid' already maps to either 'nl' or NULL. Likewise, 'nl' could be carried
:around as an integer instead of a pointer. Admittedly, a GarbageHashTable
:defeats this by casting it back to a pointer - if you use that directly
:as key - which you don't have to.

I perfectly know I'm handling a possibly dangling pointer value, and this
is the purpose of the hash table.  I know I could have used an ID in the
table, but as it is a running count it would have meant using a 64-bit
ID and that would imply the use of 64-bit atoms, and I don't want that.

But let's face it: this code works fine as it is.  An implementation of a
C compiler that would put a level of indirection to all pointer accesses
just to prevent using a pointer that has been freed would be braindead.

Otherwise, if one handles the actual pointer value not like a pointer but
as any normal integer quantity, then it is perfectly safe.  Show me a C
compiler that breaks that behaviour, i.e. which breaks the logic of
lookup_is_alive().

:> Also, these pointers are always allocated as far as the implementation
:> goes because they were allocated through malloc() underneath.  The walloc()
:> layer on top of that merely redistributes the allocated space among objects,
:> but the space is not really freed.  None of this memory is really freed.
:
:A very poor excuse. walloc() is supposed to be transparent to malloc() and
:you can compile gtk-gnutella so that it uses malloc() all the time. In
:fact for debugging that's highly recommended and by not adhereing to
:the standard you make just this more difficult.

Again, that would be Crappy, not C.  Now if I were to dereference a dangling
pointer, that would be a severe bug and it would warrant an immediate fix.

Raphael

P.S: Actually, that particular logic is older than you would think.
And it has been running just fine for the past 4 years in gtk-gnutella already.
Just look at dq_alive().

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gtk-gnutella-devel mailing list
gtk-gnutella-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to