P
Pascalus
Hi there!
I have a problem with the delete[] operator to destroy a (char*). It used to work since today. I don't know what I may
have changed in the project and/or the solution (probably in the properties or what) to cause this problem...
I have an app written in cpp.NET. In one function, I call an external function from a win32 DLL of my own. Here is the body:
#include "myDll.h"
void myCppNetFunction(...)
{
char* str = NULL;
...
myDllFunction(&str); // declared as "__declspec(dllimport) void myDllFunction(char** str);" in the header file
...
delete[] str;
}
myDllFunction() takes the address of the pointer and allocates memory for the pointer. The calling function must then
destroy the pointer after usage.
__declspec(dllexport) void myDllFunction(char** str)
{
*str = new char[...];
...
}
There is no problem when compiling and linking.
At runtime, I got an exception on the delete[] instruction, generated by a:
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
in a function called:
_CRTIMP void __cdecl _free_dbg()
in a file called:
dbgheap.c
Well, I'm not an expert at all in Managed C++ and the VS2003 environment. Is my code good or wrong?
Your help will be much appreciated !!!
Thx,
/Pascal.
I have a problem with the delete[] operator to destroy a (char*). It used to work since today. I don't know what I may
have changed in the project and/or the solution (probably in the properties or what) to cause this problem...
I have an app written in cpp.NET. In one function, I call an external function from a win32 DLL of my own. Here is the body:
#include "myDll.h"
void myCppNetFunction(...)
{
char* str = NULL;
...
myDllFunction(&str); // declared as "__declspec(dllimport) void myDllFunction(char** str);" in the header file
...
delete[] str;
}
myDllFunction() takes the address of the pointer and allocates memory for the pointer. The calling function must then
destroy the pointer after usage.
__declspec(dllexport) void myDllFunction(char** str)
{
*str = new char[...];
...
}
There is no problem when compiling and linking.
At runtime, I got an exception on the delete[] instruction, generated by a:
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
in a function called:
_CRTIMP void __cdecl _free_dbg()
in a file called:
dbgheap.c
Well, I'm not an expert at all in Managed C++ and the VS2003 environment. Is my code good or wrong?
Your help will be much appreciated !!!
Thx,
/Pascal.