A
AlabiChin
Hello,
I noticed that when I dynamically create an array of chars, the
resulting size of the allocated memory block is larger by about 15
bytes than what I specified. Here is example code:
char *createTextBuffer(char *buffer, int length)
{
buffer = new char[length];
if (buffer == NULL) {
return NULL;
}
length = strlen(buffer); // Current buffer shows larger size.
return buffer;
}
The above program causes a crash when destroying the allocated memory
via delete. I suspect the crash problem originates at the time of
allocation (i.e., possible memory corruption at time of allocation).
I am using MS Developer Studio 6.0 (SP 6) on AMD Athlon. I get the same
results on a Pentium 4. Any suggestions or comments on what I am doing
in the code is much appreciated.
TIA
Alabi
I noticed that when I dynamically create an array of chars, the
resulting size of the allocated memory block is larger by about 15
bytes than what I specified. Here is example code:
char *createTextBuffer(char *buffer, int length)
{
buffer = new char[length];
if (buffer == NULL) {
return NULL;
}
length = strlen(buffer); // Current buffer shows larger size.
return buffer;
}
The above program causes a crash when destroying the allocated memory
via delete. I suspect the crash problem originates at the time of
allocation (i.e., possible memory corruption at time of allocation).
I am using MS Developer Studio 6.0 (SP 6) on AMD Athlon. I get the same
results on a Pentium 4. Any suggestions or comments on what I am doing
in the code is much appreciated.
TIA
Alabi