Re: Size of malloc'd?
- From: "bwaichu@xxxxxxxxx" <bwaichu@xxxxxxxxx>
- Date: 29 Aug 2006 12:02:57 -0700
Eric Sosman wrote:
bwaichu@xxxxxxxxx wrote On 08/29/06 14:20,:
How do I determine the size of a previously malloc'd buffer?
char *buffer;
buffer = calloc(18, sizeof *buffer);
I cannot do a sizeof(buffer) since it would only return the size of the
pointer. I cannot do sizeof *buffer since it would only return the
size of the pointer type. Is there a right way to do this? Do I need
to manage this information in the program?
This is Question 7.27 in the comp.lang.c Frequently
Asked Questions (FAQ) list
http://www.c-faq.com/
Thanks for the link. The answer is what I expected.
Thanks!
.
- References:
- Size of malloc'd?
- From: bwaichu@xxxxxxxxx
- Re: Size of malloc'd?
- From: Eric Sosman
- Size of malloc'd?
- Prev by Date: Re: strange output
- Next by Date: Hi a strange code ....
- Previous by thread: Re: Size of malloc'd?
- Next by thread: Hi a strange code ....
- Index(es):
Relevant Pages
|