From: Christian B. <chr...@gm...> - 2008-09-16 16:00:56
|
Raphael Manfredi wrote: > Quoting Christian Biere <chr...@gm...> from ml.softs.gtk-gnutella.devel: > :I don't see what lookup_is_alive() is good for. It is not valid C if the > :pointer actually references a freed object as per C standard section 6.2.4. If > :you want to use weak references, look at core/nodes.c and "node_id". You have > :to use numeric IDs, not pointers to track objects beyond their life-cycle. > This code is perfectly valid as the pointer is used only as an integer here, > as a key in the hash table, and is never de-referenced unless it is valid 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. > (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. > Anyway, this is not the problem here. Again, I didn't say anything like that. It is a problem that became only apparent to me due to another around this code. -- Christian |