So I'm allocating arrays of pointers, which looks and can be used like 2D arrays.
I have no problems allocating the memory, but freeing it just doesn't seem to happen.
I can see from task manager, that when I call the allocation functions, the amount of memory used by the game grows.
But when it should free the same amount of memory, nothing happens in task manager, it shows the exact same amount of memory being used by the game.
Is this a bug with Game Editor, or am I freeing the memory in a wrong way?
Here are the functions used for allocation and freeing of the memory.
- Code: Select all
int ** array2D;
int allocate2Darray(int rows, int cols)
{
int i, success = 1;
array2D = malloc(rows * sizeof(int *));
if (array2D)
{
for (i = 0; i < rows; i ++)
{
array2D[i] = malloc(cols * sizeof(int));
if (!array2D)success = 0;
}
}
else success = 0;
return success;
}
void free2Darray(int rows)
{
int i;
for (i = 0; i < rows; i ++)
{
free(array2D[i]);
}
free(array2D);
}