Hai all,
I have one question in C. That is..
How will you write a routine in C to find the heap size?
if anyone knows the answer, pls post & clear my doubt.
Thanks.
-Vijay
Hai all,
I have one question in C. That is..
How will you write a routine in C to find the heap size?
if anyone knows the answer, pls post & clear my doubt.
Thanks.
-Vijay
Well, you either keep a static count of your nodes as you create and delete them and just return that to the program or you just have to iterate through the whole thing counting the non null nodes. And of course if you mean memory size, you just simply count up the number of nodes and multiply by sizeof(*node).
Who knows, maybe there is some other magic routine I'm not thinking of right now. As far as I can see, those are your best bets.
Sent from my iPadŽ
> How will you write a routine in C to find the heap size?
Read the manual pages and documentation which come with your compiler.
There's no standard way to know this information.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you're using linux then read up on the sbrk() function. You can record the return value once when your program starts and then compare that value with sbrk()'s current return value every time you want to query.
If you understand what you're doing, you're not learning anything.
I always do this. I can't believe how stupid I am, I never learn. I see the word heap and I think of the data structure. Of course they're talking about runtime memory though.
Someone slap me, I deserve it.
Sent from my iPadŽ