Summary: Memory Management Functions
void *malloc(size_t nbytes)
- aim: allocate some memory for a data object
- attempt to allocate a block of memory of size
nbytes in the heap
- if successful, returns a pointer to the start of the block
- if insufficient space in heap, returns
NULL
Things to note:
- the initial contents of the memory block are random
- returned address should be cast to appropriate pointer type
|