Re: Size of malloc'd?
- From: Eric Sosman <Eric.Sosman@xxxxxxx>
- Date: Tue, 29 Aug 2006 14:53:12 -0400
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/
--
Eric.Sosman@xxxxxxx
.
- Follow-Ups:
- Re: Size of malloc'd?
- From: bwaichu@xxxxxxxxx
- Re: Size of malloc'd?
- References:
- Size of malloc'd?
- From: bwaichu@xxxxxxxxx
- Size of malloc'd?
- Prev by Date: Re: Proper way to turn off debug macros at compile time.
- Next by Date: Re: strange output
- Previous by thread: Re: Size of malloc'd?
- Next by thread: Re: Size of malloc'd?
- Index(es):
Relevant Pages
|