BOster
Legendary Poster
I have used jdeReAllocEx in the past w/o any issues (although sparingly, I often find myself using a link list when I have a dynamically growing array). I have been banging my head against the wall all morning with it though. It has intermittently been failing by not allocating memory and causing jde to crash when making the first call to do the initial allocation.
In other words the following fails:
ZCHAR *line=(ZCHAR *)NULL;
if(size == 0)
size = len + 1;
else
size += len;
line = jdeReAllocEx(line, size);
The following doesn't seem to have any issues:
if(size == 0)
{
size = len + 1;
line = jdeAlloc(COMMON_POOL, size, MEM_ZEROINIT);
}
else
{
size += len;
line = jdeReAllocEx(line, size);
}
Are you allways supposed to call jdeAlloc for the initial malloc? I have never done this in the past either in jde or out and if jdeReAllocEx is supposed to work the same way as realloc then, based on the documentation, I can just use jdeReAllocEx. Obviously I could have some sort of buffer overrun someplace else, but its weird that by making my initiall allocation call to jdeAlloc I don't see any issues.
In other words the following fails:
ZCHAR *line=(ZCHAR *)NULL;
if(size == 0)
size = len + 1;
else
size += len;
line = jdeReAllocEx(line, size);
The following doesn't seem to have any issues:
if(size == 0)
{
size = len + 1;
line = jdeAlloc(COMMON_POOL, size, MEM_ZEROINIT);
}
else
{
size += len;
line = jdeReAllocEx(line, size);
}
Are you allways supposed to call jdeAlloc for the initial malloc? I have never done this in the past either in jde or out and if jdeReAllocEx is supposed to work the same way as realloc then, based on the documentation, I can just use jdeReAllocEx. Obviously I could have some sort of buffer overrun someplace else, but its weird that by making my initiall allocation call to jdeAlloc I don't see any issues.