This may or may not be related, but how/why are you declaring m_lMap again inside the else statement? It obviously already exists if you are testing it for NULL.
void MapHandler::addMapRow(int Y){
if(m_lMap == NULL)
{
m_lMap = new NavGraphNode*[Y+1];
m_lMap[0] = new NavGraphNode[arraySizeX];
}
else
{
int** tempMap = newint*[Y+1]; // this is where I get the bad_alloc error
int x=0;
for(int y=0;y<Y;y++)
{
tempMap[y] = new NavGraphNode[arraySizeX];
x=0;
for(;x<arraySizeX;x++)
{
tempMap[y][x] = m_lMap[y][x];
}
}
}
}
//where m_lMap is a int**.
m_lMap is in gloabal scope, MapHandler has the variable as private.
hmm... only thing I do elsewhere is to alter the NavGraphs that were created in the m_lMap the first time. And when I've done that I'm trying to add new rows to the m_lMap somehow.
This was the only way I could figure you'd do it