I always thought that Microsoft's malloc() returned a fully valid heap
pointer when you pass a size of zero. Such a pointer would be a valid heap
pointer of zero size (consisting only of a heap linked list entry "before"
the pointer), and could be freed with free().
realloc() does free() and returns NULL if _size is zero. This is even true
if you originally passed zero to malloc() and got an empty heap pointer. In
this way, realloc is inconsistent with malloc(), but that's the way it is.
Melissa
----- Original Message -----
From: "D. Hazelton" <dhazelton(a)enter.net>
To: <ros-dev(a)reactos.org>
Sent: Saturday, June 03, 2006 15:44
Subject: Re: [ros-dev] [ros-diffs] [greatlrd] 22195: make malloc,calloc and
some other function return NULL if size is 0
Sorry about that last post. I forgot that MS never
follows published
specifications. The ANSI C standard states that malloc() of any memory
should
either allocate the memory or fail - most implementations of the standard
C
library return NULL on a call to malloc with 0 as the size.
Calls to realloc() with size as 0 are supposed to free the pointer.
However, MS doesn't follow ANSI at all, anywhere, and since ReactOS is
meant
to be 100% binary compatable with Windows it should follow the MSDN specs
for
functions.
DRH
_______________________________________________
Ros-dev mailing list
Ros-dev(a)reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev