Search:
Forum
General C++ Programming
malloc: size of allocated area?
malloc: size of allocated area?
Jun 11, 2008 at 8:21am UTC
luckycusp
(105)
How to find the size of area allocated by malloc?? is it even possible.
for example:-
void *ptr;
ptr = malloc(10);
Here malloc should allocate 10bytes...
Can i check it in my program using 'ptr' variable, how many bytes are allocated??
Maybe using sizeof().. but how?
Jun 11, 2008 at 9:18am UTC
bnbertha
(401)
There is no standard way of doing this. You may be lucky and your implementation/platform has an extension to do this but otherwise the only way is to track it yourself from when the
malloc()
was done.
See this C language FAQ
http://c-faq.com/malloc/querysize.html
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs