Page 1 of 6
1 2 3 6

Programming in C

C standard library function – free()

In dynamic memory allocation the memory have to be deallocated explicitly. It releases all the used memory spaces previously allocated by calloc(), malloc() or realloc() functions. If we no longer need the data stored in a particular block of memory, then we should have a practice to release that memory for future use. After freeing the memory blocks the memories are returned to heap.

C standard library function – realloc()

Realloc stand for Reallocation. At the time of memory allocation using calloc() or malloc(), it may be possible memory is excess or insufficient. So for that reason we need to reallocate memory at the run time. realloc() is used to dynamically reallocate those memory without losing the data.

C standard library function – calloc()

Calloc stands for Contiguous Allocation. To allocate memory dynamically we also use the function which is called as calloc() function. calloc() function on success returns the base address of the array and every memory location will be initialized to 0. Whereas in malloc() it was initialized by a garbage value.

C standard library function – malloc()

In case of static memory allocation there are some drawbacks like: wastage of memory, less flexibility, permanent allocation of variables etc. To overcome these situations the concept of Dynamic Memory Allocation has been introduced. In dynamic memory allocation the memories can be allocated dynamically at run time. There 4 library functions that are described under <stdlib.h> …

C standard library function – malloc() Read More »