Paul Sander wrote :
|| 
|| An "isValid" field isn't valid if the structure isn't initialized properly.
|| When this is a concern, the value of the pointer itself becomes significant
|| (like it is with the NULL pointer, but when its value must also be
|| distinguishable from NULL).  In such cases, a pointer to block of zero bytes
|| makes sense to some people.  (In some such cases, it's just as valid to assign
|| to the pointer the address of a statically allocated structure.  But sometimes
|| it's not known in advance how many such pointers are needed, so the structures
|| must be dynamically allocated.)
|| 
|| As for how to tell it apart from a "good" allocation, the pointer is usually
|| stored in some well-known place at the time the allocation is done, usually
|| when a program or structure is being initialized.  An arbitrary pointer's
|| value is compared with that stored in the well-known place when the special
|| value is of interest.

But if no memory is actually allocated, how do you ensure that the
address of the zero-length chunk is different?  Since it didn't use
any memory, the same memory address is still free and is likely to be
returned as the result of the next allocation request too.  Rather
than trust the alloc routine to carry out an impossible task for
which it was not desgined, you are better off the allocate a real
memory area for unique flag values to ensure they are unique.

-- 
Sleep should not be used as a substitute    | John Macdonald
for high levels of caffeine  -- FPhlyer     |   [EMAIL PROTECTED]

Reply via email to