S
Spikinsson
I create a new char[] and when I attempt to delete it, the debug gives this error (during
runtime):
Debug Error!
Program: xxx
DAMAGE: after Normal block (#58) at 0x00C315A0.
I get this error everywhere I use delete []. When I remove all delete []'s from my code I
don't get the errors (nor does the program sometimes crash in release version
compilation), but I can't do that can I (memory leaks).
This is a part of my code:
** BEGIN **
int a = 0;
char *name = NULL;
a = GetWindowTextLength(GetDlgItem:hwnd, IDC_NAME)) + 1;
if (!(name = new char[a]))
{
MessageBox:hwnd,"Not enough memory to allocate the
value!",NULL,MB_OK|MB_ICONERROR);
return;
}
GetDlgItemText:hwnd, IDC_NAME, name, a);
// THIS GIVES THE ERROR:
delete [] name;
** END **
When I check the name value, it does give the expected value!
I use MSVC++ 6.0 by the way.
I am pretty new at programming C++ and any help is very much appreciated, I really can't
figure out this one...
runtime):
Debug Error!
Program: xxx
DAMAGE: after Normal block (#58) at 0x00C315A0.
I get this error everywhere I use delete []. When I remove all delete []'s from my code I
don't get the errors (nor does the program sometimes crash in release version
compilation), but I can't do that can I (memory leaks).
This is a part of my code:
** BEGIN **
int a = 0;
char *name = NULL;
a = GetWindowTextLength(GetDlgItem:hwnd, IDC_NAME)) + 1;
if (!(name = new char[a]))
{
MessageBox:hwnd,"Not enough memory to allocate the
value!",NULL,MB_OK|MB_ICONERROR);
return;
}
GetDlgItemText:hwnd, IDC_NAME, name, a);
// THIS GIVES THE ERROR:
delete [] name;
** END **
When I check the name value, it does give the expected value!
I use MSVC++ 6.0 by the way.
I am pretty new at programming C++ and any help is very much appreciated, I really can't
figure out this one...