Quick question on LocalAlloc & new operator
Hi,
Juz have a quick question on the following operator:
New
Does the new and delete must be within the same function?
For instance,
PHP Code:
char *lpszBuffer=NULL;
void Function1 (void)
{
lpszBuffer = new char[128];
}
void Function2 (void)
{
delete [] lpszBuffer;
}
// Or must be in this...
void Function1 (void)
{
lpszBuffer = new char[128];
:
:
delete [] lpszBuffer;
}
LocalAlloc
Does the we need to cast the pointer when we call the LocalFree?
For instance,
PHP Code:
void Function1 (void)
{
LPSTR lpszBuffer = (LPSTR)LocalAlloc(LPTR, 128);
:
:
:
LocalFree (lpszBuffer);
}
// Or this way...
void Function1 (void)
{
LPSTR lpszBuffer = (LPSTR)LocalAlloc(LPTR, 128);
:
:
:
LocalFree ((LPSTR)lpszBuffer);
}
regards,
Chris.C