Game Development Community

System crash

by Nabarro · in Torque 3D Professional · 06/30/2010 (6:12 am) · 1 replies

System sometimes crash, and it stops at below point by using MS VS 2005:

stringTable.cpp:

void _StringTable::resize(const U32 newSize)
{
Node *head = NULL, *walk, *temp;
U32 i;
// reverse individual bucket lists
// we do this because new strings are added at the end of bucket
// lists so that case sens strings are always after their
// corresponding case insens strings

for(i = 0; i < numBuckets; i++) {
walk = buckets[i];
while(walk)
{
temp = walk->next; (crash and stop here)
walk->next = head;
head = walk;
walk = temp;
}
}
...
It seems that temp's value is illigal: 0xffffffbe.

Also in this function:
buckets = (Node **) dRealloc(buckets, newSize * sizeof(Node));
Should it be:
buckets = (Node **) dRealloc(buckets, newSize * sizeof(Node *));

Anyone may help to look at this? Thanks,

#1
07/01/2010 (12:40 am)
Realloc with a sizeof(Node) instead of sizeof(Node*) won´t hurt, unless Node is smaller than Node* (what might obviously not been the case). The only issue you have is using some more memory then.

More important is, that buckets were initialized in a correct manner via
memset( buckets+oldSize, 0, (newSize-oldSize) * sizeof(whatsallocated) );
or you write your own fast memfill function instead. ;-)

this should help you in your crash problem!

//Edit: changed code for realloc function!