Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>free() deallocate memory block</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 free()                  Deallocate Memory Block

 #include   <stdlib.h>                   Required for declarations only

 void       free(ptr);
 void       *ptr;                        Pointer to already allocated block

    free() deallocates the previously allocated memory block pointed to
    by 'ptr'.  The block must have been allocated by calloc() or malloc()
    and may have been reallocated or resized by realloc().  This makes
    the memory in the block available for reallocation.

       Returns:     There is no return value.

         Notes:     free() deallocates the number of bytes that were
                    allocated in the call to calloc(), malloc(), or
                    realloc().

   -------------------------------- Example ---------------------------------

    The following statements allocate space for 1000 bytes and then free
    the allocated space.

           #include <stdlib.h>     /* for free */
           #include <stdio.h>      /* for printf and NULL */

           char *memptr;

           main()
           {
               if ((memptr = malloc(1000)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    free(memptr);
                }
           }



See Also: malloc() calloc()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson