Joe said:
pete wrote:
Marcelo wrote:
Is it necessary to make a free for other statements than malloc ones?
I mean, I have just to execute free()
to the variables that have been explicitly
used with malloc() ???
There's also calloc and realloc to consider.
realloc is also capable of freeing memory.
I've heard that but don't find a Standard reference to it. I think you
mean that 'realloc(ptr, 0);' is the same as 'free(ptr);'. Can you
provide a Standard reference? Thanks.
N869
7.20.3.2 The free function
Description
[#2] The free function causes the space pointed to by ptr to
be deallocated, that is, made available for further
allocation. If ptr is a null pointer, no action occurs.
Otherwise, if the argument does not match a pointer earlier
returned by the calloc, malloc, or realloc function, or if
the space has been deallocated by a call to free or realloc,
the behavior is undefined.
7.20.3.4 The realloc function
Description
[#2] The realloc function deallocates the old object pointed
to by ptr