[prev] [index] [next]

Memory Management

void free(void *ptr)
  • releases a block of memory allocated by malloc()
  • *ptr is a dynamically allocated object
  • if *ptr was not malloc()'d, chaos will follow
Things to note:
  • the contents of the memory block are not changed
  • all pointers to the block still exist, but are not valid
  • the memory may be re-used as soon as it is free()'d