Sender: nate AT cartsys DOT com Message-ID: <361182CA.BD6F9ED8@cartsys.com> Date: Tue, 29 Sep 1998 18:00:58 -0700 From: Nate Eldredge X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.35 i486) MIME-Version: 1.0 To: Ilya Ryzhenkov CC: djgpp workers list Subject: Re: Just a question References: <3610D3F3 DOT 8DA204E0 AT inetlab DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ilya Ryzhenkov wrote: > > Hi! > > Is there any standards of what should malloc(0) return ? > Should it return NULL or a valid address with zero (actually > minimum chunk) size ? The OpenGroup spec says that it may either return NULL or a cookie (presumably a valid address) that can be passed to `free'. Personally, I would be inclined to return NULL, since dereferencing the pointer would be an error. http://www.opengroup.org/onlinepubs/7908799/xsh/malloc.html > And, as a dependent, how must realloc(ptr,0) behave ? Should it > be equal to free(ptr) and return NULL or behave in other way ? It's freed, and returns, like malloc(0), either NULL or a meaningless cookie. http://www.opengroup.org/onlinepubs/7908799/xsh/realloc.html -- Nate Eldredge nate AT cartsys DOT com