If I have a struct of ints, do I have to individually free all of the ints (they are not pointers), or will they be freed when I call free() on the struct?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, they will be freed when the entire struct is freed.
(Note that you only need to
freea struct that was allocated withmalloc/calloc/realloc, not one that was allocated on a stack.)