 st8b7c:f320:99b9:690f:4595:cd17:293a:c069free    Defined in header <cstdlib>         void free( void* ptr );
       Deallocates the space previously allocated by st8b7c:f320:99b9:690f:4595:cd17:293a:c069malloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069calloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069aligned_alloc (since C++17), or st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc.
If ptr is a null pointer, the function does nothing.
The behavior is undefined if the value of ptr does not equal a value returned earlier by st8b7c:f320:99b9:690f:4595:cd17:293a:c069malloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069calloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069aligned_alloc (since C++17), or st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc.
The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, st8b7c:f320:99b9:690f:4595:cd17:293a:c069free or st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc has already been called with ptr as the argument and no calls to st8b7c:f320:99b9:690f:4595:cd17:293a:c069malloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069calloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069aligned_alloc (since C++17), or st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc resulted in a pointer equal to ptr afterwards.
The behavior is undefined if after st8b7c:f320:99b9:690f:4595:cd17:293a:c069free returns, an access is made through the pointer ptr (unless another allocation function happened to result in a pointer value equal to ptr).
 
 The following functions are required to be thread-safe:

 The library versions of operator new and operator delete 
 User replacement versions of global operator new and operator delete 
 st8b7c:f320:99b9:690f:4595:cd17:293a:c069calloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069malloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc, st8b7c:f320:99b9:690f:4595:cd17:293a:c069aligned_alloc (since C++17), st8b7c:f320:99b9:690f:4595:cd17:293a:c069free 
 Calls to these functions that allocate or deallocate a particular unit of storage occur in a single total order, and each such deallocation call happens-before the next allocation (if any) in this order.
 (since C++11)
   Parameters    ptr   -   pointer to the memory to deallocate 

  Return value (none).
 Notes The function accepts (and does nothing with) the null pointer to reduce the amount of special-casing. Whether allocation succeeds or not, the pointer returned by an allocation function can be passed to st8b7c:f320:99b9:690f:4595:cd17:293a:c069free.
 Example  #include <cstdlib>
 
int main()
{
    int* p1 = (int*)st8b7c:f320:99b9:690f:4595:cd17:293a:c069malloc(10*sizeof *p1);
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069free(p1); // every allocated pointer must be freed
 
    int* p2 = (int*)st8b7c:f320:99b9:690f:4595:cd17:293a:c069calloc(10, sizeof *p2);
    int* p3 = (int*)st8b7c:f320:99b9:690f:4595:cd17:293a:c069realloc(p2, 1000*sizeof *p3);
    if(!p3) // p3 null means realloc failed and p2 must be freed.
       st8b7c:f320:99b9:690f:4595:cd17:293a:c069free(p2);
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069free(p3); // p3 can be freed whether or not it is null.
}   See also    C documentation for free 
  

    
{'path': 'public/docs/cpp/memory/c/free.html', 'source': 'DevDocs.IO'}