Skip to content

Tag Archives: C-Dynamic Memory Allocation

Consider the following three C functions : [PI] int * g (void)  {    int x= 10;    return (&x);  }        [P2] int * g (void) … Read More
The most appropriate matching for the following pairs (GATE CS 2000) X: m=malloc(5); m= NULL;        1: using dangling pointers Y: free(n); n->value=5;         2: using uninitialized… Read More
Question: How to deallocate dynamically allocate memory without using “free()” function. Solution: Standard library function realloc() can be used to deallocate previously allocated memory. Below… Read More
  A typical memory representation of a C program consists of the following sections.1. Text segment 2. Initialized data segment 3. Uninitialized data segment 4. Stack 5. Heap  A… Read More
Consider the following prototype of free() function which is used to free memory allocated using malloc() or calloc() or realloc(). void free(void *ptr); Note that… Read More
Size of dynamically allocated memory can be changed by using realloc(). As per the C99 standard: void *realloc(void *ptr, size_t size); realloc deallocates the old… Read More
Pre-requisite: Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc() The name malloc and calloc() are library functions that allocate memory dynamically. It… Read More
Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers which by definition never terminate.