How can I free automatically multiple malloc in C? -


i'd free automatically multiple malloced memory @ end of program in c.

for example :

str1 = malloc(sizeof(char) * 10); str2 = malloc(sizeof(char) * 10); str3 = malloc(sizeof(char) * 10); 

i don't want function :

void   my_free() {     free(str1);     free(str2);     free(str3); } 

but function free memory allocated during program.

but function free memory allocated during program.

there's no such function in c. c doesn't memory management automatically. it's responsibility track memory allocations , free them appropriately.

most modern operating systems (perhaps, not embedded systems) reclaim memory allocated during execution @ process termination. can skip calling free(). however, if application long running 1 become problem if keeps allocating memory. depending application, may devise strategy free memory appropriately.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -