Im getting double free error's from this? Why?
2d array standard implementation. any clues?

  int **m = malloc(5 * sizeof(int));

  int i,j;
  for(i = 0; i < 5; i++)
        m[i] = malloc(5 * sizeof(int));


        for(i = 0; i< 5; i++)
                free(m[i]);

        free(m);

in line 1, it should be

malloc(5*sizeof(int*));

you have to allocate memory for a int pointer, not integer. try this. ;)

please mark this thread as solved, it will be helpful for everyone ;)

A good trick for avoiding this type of mistake is taking the size of the destination pointer rather than hardcoding the type:

int **m = malloc(5 * sizeof *m);
...
m[i] = malloc(5 * sizeof *m[i]);

This works because sizeof doesn't actually perform the dereference, it just evaluates to the size of the result as if had it been performed.

commented: cool :) +3
commented: awesome trick i must say ;) +2