Raphael Manfredi wrote: > Quoting Christian Biere <[EMAIL PROTECTED]> from ml.softs.gtk-gnutella.devel: > :Nobody said a word about dereferencing and if you had actually read the > :section, you'd know that just using the pointer's value leads to > :undefined behavior. > > That C is just braindead.
What's more braindead: writing code in a language of which you never bothered to read the specification of or some odd rule whose purpose you don't grasp or like? > If you look at the flow, you'll see that the > pointer's value is actually not used as a pointer but as an integer. That's just nonsense. > The fact that it is carried by pointer variables is just due to the fact > that the hash table only works with pointers. Nobody forces you to use GarbageHashTable or whatever the 'G' in GLib stands for. > :> (presence in the table means the pointer is valid). > :Then you don't need the check for "lid" at all. If it's supposed to be a > :consistency check that's fine but then it should be an assertion check. > :If you intend to leave dangling pointers in the table and use the check > :to avoid recycled memory, then it's not. > If the pointer is present in the table, then it is allocated, not dangling. 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. > 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. -- Christian ------------------------------------------------------------------------- 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