C Dynamic Memory Allocation

Contents

  • Dynamic Memory Allocation
  • Memory allocations process
  • Allocating a block of memory
  • Allocating multiple blocks of memory
  • Releasing the used space
  • To alter the size of allocated memory

Dynamic Memory Allocation

In programming we may come across situations where we may have to deal with data, which is dynamic in nature. The number of data items may change during the executions of a program.
The number of customers in a queue can increase or decrease during the process at any time. When the list grows we need to allocate more memory space to accommodate additional data items.
Such situations can be handled move easily by using dynamic techniques. Dynamic data items at run time, thus optimizing file usage of storage space.

Functions of memory management

  • Malloc - Allocates memory requests size of bytes and returns a pointer to the Ist byte of allocated space
  • Calloc - Allocates space for an array of elements initializes them to zero and returns a pointer to the memory
  • Free - Frees previously allocated space
  • Realloc - Modifies the size of previously allocated space.


Make Comments..!!


Oops!! No posts from user.

Download Android App