[LUGOS-PROG] calloc(0,0) != NULL
Rok Papež
rok.papez at kiss.uni-lj.si
Sun Apr 21 10:52:46 CEST 2002
Zivjo!
On Friday 19 April 2002 22:17, Dejan Markic wrote:
> Single UNIX specification:
> If the size of the space requested is 0, the behaviour is
> implementation-dependent; the value returned will be either a null pointer
> or a unique pointer.
Ja.. tezava je v tem, ker moj malloc/calloc man-page cisto nic ne omenja
tega, da malloc(0) lahko vrne non-null. In potem seveda ASSumption naredi
svoje ;-))).
> Linux:
> if size is equal to zero, the call is equivalent to free(ptr).
> free() tud ne bo settal ptr na NULL
to je za realloc.
> Zakaj linux ne vrne NULL ...
> We chose to make malloc(0) return non-null in glibc for the same reason:
> because some existing program assumed it would.
Kje si pa to nasel ? Info malloc mi namrec tudi vrne samo man page od malloc
kjer o tovrstnem obnasanju ni nic napisano.
> NULL bo pa v vsakem primeru vrnila funkcija ob napaki.
Ja.. mi je res v veliko tolazbo :-).
--
best regards,
Rok Papež.
More information about the lugos-prog
mailing list