Check out example codes for "free in c". It will help you in understanding the concepts better.

Code Example 1

//malloc or "memory allocation" reserves a part of the memory  pointer = (cast-type*) malloc(byte-size)    //Example ptr = (int*) malloc(100 * sizeof(int));  Since the size of int is 4 bytes, this statement will allocate 400 bytes of memory. And, the pointer ptr holds the address of the first byte in the allocated memory.

Code Example 2

the C library function void free(void *ptr)    deallocates the memory previously allocated by a call to calloc, malloc, or realloc.

Learn ReactJs, React Native from