Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft 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   <malloc.h>                   Required for declarations only

 void       free(ptr);
 char       *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().

                Use hfree() to free memory allocated by halloc().

                Use _ffree() to free memory allocated by _fmalloc().

                Use _nfree() to free memory allocated by _nmalloc().

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

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

           #include <malloc.h>
           #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() _ffree() _nfree() hfree()

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