The standard library is a header file in C that gives us gives us data types and functions for dynamic memory allocation. See this link for a full guide.

Macros

  • EXIT_FAILURE: for an exit status in case of error in program termination.
  • EXIT_SUCCESS: counterpart to above. Equivalent to returning 0.

Functions

  • void *malloc(size_t num): allocates requested number of bytes in the heap and returns a pointer to that memory.
  • void* calloc(size_t num, size_t sizeoftype): alternative to malloc that is debatably clearer.
  • void *realloc(void *ptr, size_t num): resizes the memory block at ptr that was previously allocated; can fail if the heap has no space. Equivalent to malloc if first argument is NULL.
  • void free(void *ptr): de-allocates memory that was previously dynamically allocated on the heap.