From: Suma C <gsumac@gmail.com>
To: C programming list <linux-c-programming@vger.kernel.org>
Subject: malloc with size 0
Date: Thu, 22 Dec 2005 10:13:57 +0530 [thread overview]
Message-ID: <1f5f62170512212043w17e1c8e7v3781e0dc72845efc@mail.gmail.com> (raw)
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;
}
next reply other threads:[~2005-12-22 4:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-22 4:43 Suma C [this message]
2005-12-22 6:21 ` malloc with size 0 Hareesh Nagarajan
2005-12-22 7:42 ` Suma C
2005-12-22 13:02 ` Neil Horman
2005-12-30 14:16 ` mail-lists
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f5f62170512212043w17e1c8e7v3781e0dc72845efc@mail.gmail.com \
--to=gsumac@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).