[prev] [index] [next]

The malloc() function (cont)

malloc() returns a pointer to a data object of some kind.

Things to note about objects allocated by malloc():

  • they exist until explicitly removed   (program-controlled lifetime)
  • they are accessible while some variable references them
  • if no active variable references an object, it is garbage
The function free() releases objects allocated by malloc()