calculating the size of a linked list

Started by
0 comments, last by JohnBolton 17 years, 4 months ago
Hi, I would like to be able to calculate the memory in use by my linked list, problem is, if i just add all the mallocs i do for every node i add i just get the size of the empty node, and seeing as all the members are pointers, i would get x times a pointer size. It would seem more proper to count the nodes and the memory they use as well right ? These members however are malloced by strdup, so i'm not sure how much they take and i'm also not sure how i would go about this. Any suggestions most welcome! gr,
Advertisement
strdup presumably allocates just enough memory to hold the string -- strlen(s)+1.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement