0

1. any problem if i dynamically allocate memory and use only a small part of it?
2. can i free the dynamic memory after each time the function is executed?

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by vineeshvs
0

is the position of 'free a' in pgm correct?

function(variables)
{
a=malloc(...);
....
return a;
free a; //is this the correct position to free a?
}

Edited by vineeshvs: n/a

1

No -- reverse the order of lines 5 and 6. As it is, line 6 will never get executed because the function exits on line 5.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.