Is there a way to find out how much memory a linked list takes up?
Is there a way to find out how much memory a linked list takes up?
Count the number of items in the list, multiply by the size of a single item. That should do it unless you allocate memory inside of each item, then you'd have to save that and read it later.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
how do I find the memory that a single node takes up?
sizeof(struct node);
or
sizeof(*head);
or anything equivalent.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
thanks for your help
It's the same value to passed to the malloc() function when you created said node.Originally posted by AmazingRando
how do I find the memory that a single node takes up?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]