Thanks Uhrwerk!

1. Would this free all the allocated memory?
Code:
for(tx=0;tx<1000;tx++)
{
	for(ty=0;ty<500;ty++)
	{
		free((Bwater[tx])[ty]);
	}
}


Would there be a ton of pointers left-over? If so, how would I remove those?



2. I still dont understand "memset( Bwater[j] , (int)100 , (int)500 * sizeof(int) );"
Running the following code testi=1684300900
Code:
int** Bwater = NULL;
int testi;

void test_array()
{
	Bwater = (int**)sys_malloc( (int)1000 * sizeof(int*) );
	int j;
	for (j=0;j<1000;j++)
	{
		Bwater[j] = (int*)sys_malloc( (int)500 * sizeof(int) );
		
		memset( Bwater[j] , (int)100 , (int)500 * sizeof(int) );
	}
	testi=(Bwater[999])[499];
}


anyone know why testi=1684300900 instead of 100?
EDIT:
For anyone just popping in that wants to help, the above code is supposed to be a subsitute for an array "int Bwater[1000][500];"
With a final line at the end to use "testi" to retrieve the value of the last position in the array [999],[499] to test if it works.

Last edited by Carlos3DGS; 02/05/13 20:02.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1