I want to call a function that uses my 2d dynamic array to create another 2d dynamic array and then rewrite the value for my first array. So the code is something like this:
#include <stdio.h>
#include <stdlib.h>
int **bigger(int **A)
{
    int i;
    int **A2 = (int **)malloc(10 * sizeof(int *));
    for(i = 0; i < 10; i++)
        A2[i] = (int *)malloc(10 * sizeof(int));
    return A2; 
    }
int main(void)
{
    int i;
    int **A = (int **)malloc(5 * sizeof(int *));
    for(i = 0; i < 5; i++)
        A[i] = (int *)malloc(5 * sizeof(int));
    A = bigger(A);
    for(i = 0; i < 10; i++)
        free(A[i]);
    free(A);
    return 0;
}
If I check it with valgrind --leak-check=yes I get total heap usage: 6 allocs, 3 frees, 240 bytes allocated. How can I solve this memory leak ?
 
    