-
free RAM memory
how can we delete char, int, FILETIME?? I delete char from ram like this:
Code:
char* recent = (char*) malloc(256);
........
free(recent);
but others??..
and I have one more questions.. exampla: we have deneme char from asd function(not in main function).. when deneme char cleaned from RAM memory.. while closed function or while closed exe??? sory my english :(
-
You only need to free memory allocated on the heap with malloc()/calloc()/alloc() (in C) or new() (in C++). If allocated with malloc()/calloc()/alloc(), then you use free() to free the memory; if allocated with new(), then use delete to free the memory).
Other variables are created on the stack and will be "freed" when the function in which they're declared goes out of scope.
Also, do not cast the result of malloc; it is unnecessary and potentially hides important errors. If you need to cast it because you are receiving errors, it is because you are compiling a C program using C++. If you are really using C++, you should be allocating memory with new instead.