PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Dynamic Matrix problems

I am having trouble deleting a dynamic matrix in Vis Studio .net. I am almost positive this code works in G++, have any ideas??

Code:

//creation seems to work fine
short **mapTiles=NULL;

mapTiles=new short*[mapX];
for(int i=0;i<mapX;i++)
{
mapTiles[i]=new short[mapY];
}
//after being created, various functions dont seem to have a problem with this


//having trouble with deletion
if(mapTiles!=NULL)
{
for (int i = 0; i < mapX; i++)
{
delete []mapTiles[i];
}
delete []mapTiles;
}
That code looks fine. Most likely you're trashing your array somewhere else.

Dan East
Ah, I got it. I was storing info directly into it from a file instead of buffering then typecasting the info to the matrix type. Thanks Dan :).