[EMAIL PROTECTED] on 05/03/2000 12:44:09 AM
>>I was looking at that, too. I tend to feel that 0-byte allocations should be
>>allowed (returning NULL) and, if systems' frees don't handle NULL properly,
>>there should be an xfree() that'll do so.
>
>I can see the occasional need to allocate a unique pointer that points to
>nowhere but is distinguishable from any other pointer, even NULL. Having a
>malloc-like function that does this (allocate a block of memory at least 0
>bytes long and return a pointer to it) is useful, and if it's implemented as
>a wrapper that increments a 0 size then so be it.
>
>This practice is typically used when there's a distinction to be made
>between an "unset" value and a "set but unspecified" value. An example
>of such data in CVS are commit comments: Comments can be prompted for if
>the string is unset. Or, an empty comment can be stored (without a prompt)
>if the string is set but unspecified.
>
>This is a somewhat contrived example because for strings this distinction
>is made by using a NULL pointer for an unset value, and a pointer to an
>empty string for a set but unspecified value. But for structures the
>distinction is a little harder to implement, and special pointers are
>one economical way to do it. Timestamps are another type of data where
>this distinction might be important, in many applications.
I don't understand why anyone would ever request a zero-byte allocation for a
struct nor how they'd be able to tell it apart from a "good" allocation. IMHO,
the way to perform the above would be to have an "isValid" field within the
struct.
Noel
This communication is for informational purposes only. It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction, unless specifically agreed
otherwise. All market prices, data and other information are not warranted as
to completeness or accuracy and is subject to change without notice. Any
comments or statements made herein do not necessarily reflect those of
J.P. Morgan & Co. Incorporated, its subsidiaries and affiliates.