linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* malloc with size 0
@ 2005-12-22  4:43 Suma C
  2005-12-22  6:21 ` Hareesh Nagarajan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Suma C @ 2005-12-22  4:43 UTC (permalink / raw)
  To: C programming list

Hi all

When  a 0 is passed to malloc, I get a valid pointer instead of a NULL
.What does this mean?

thanks  in advance

regards
suma

PS:
code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
        char  *ptr = NULL;
        ptr = malloc(0);
        printf("ptr :%u \n",ptr);
        strcpy(ptr,"abcdefghijkl");
        printf("%s\n",ptr);  //no seg fault here????
        return 0;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-12-30 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-22  4:43 malloc with size 0 Suma C
2005-12-22  6:21 ` Hareesh Nagarajan
2005-12-22  7:42   ` Suma C
2005-12-22 13:02 ` Neil Horman
2005-12-30 14:16 ` mail-lists

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).