+ 2

Memory management

Someone know if there is a function allowing to release more than one pointer once. Instead of doing : free(fptr) free(fptr1) free(fptr2)

28th May 2020, 9:51 PM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
10 ответов
30th May 2020, 6:26 PM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
+ 4
you will have to create such function yourself
28th May 2020, 10:14 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
Zia sahebi But closing the program does not automatically free allocated data so the program will leak memory (which may or may not be reclaimed by the operating system) and even if it does, it's a bad practice and not something you can expect if you want your program to be portable.
29th May 2020, 6:39 AM
Gen2oo
Gen2oo - avatar
30th May 2020, 6:25 PM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
+ 3
In C++, you could do this quiet easily with template parameters: https://code.sololearn.com/c0C849P8kr3z/?ref=app
14th Jun 2020, 11:52 PM
SapphireBlue
SapphireBlue - avatar
+ 2
i say instead of doing many free(..) is it a function in standard library can do that once. exemple : function_delete(ptr1, ptr2...)
28th May 2020, 10:11 PM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
+ 2
yea i can do it but i would be sure that he doesn't exist
28th May 2020, 10:17 PM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
+ 2
No there is no way to free all of your alloced heap memory at once except closing your programm!
29th May 2020, 3:55 AM
Zia sahebi
0
Gen2oo Usually every OS has an memory protection to avoid occur OS memory leak
29th May 2020, 6:49 AM
Zia sahebi