c - Dynamically allocate and free memory in local functions -


consider following function:

void free_or_not ( int count ) {     int ;     int *ip = malloc ( count * sizeof ( int ) ) ;      ( = 0 ; < count ; ++ )         ip[i] = ;      ( = 0 ; < count ; ++ )         printf ( "%d\n" , ip[i] ) ;      free ( ip ) ; } 

will cause memory leak if don't call free() inside free_or_not()?

yes,when function finishes, lose pointer allocated memory free() it.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -