I am building an application consisting of the following, separate modules: - GAClient: a C++ executable - GAOrcl: a C DLL generated by Oracle Pro*C - GAEngine: a C++ DLL - MyGAUtils: a C++ library of functions
Here's how the different modules are related: - GAClient calls several functions from GAOrcl, and a few from MyGAUtils; - GAOrcl calls a few functions from GAEngine ("DoGATraining" is one of them) - GAEngine calls several functions from MyGAUtils
I have two similar instructions in GAClient.cpp:
double* vKaz=(double*)malloc(5*sizeof(double*));
and GAEngine.cpp:
double* vPastTarget=(double*)malloc(5*sizeof(double*));
My problem is, malloc works fine when called from GAClient, but subsequently crashes when called from GAEngine. Visual Studio debugger throws a "GAClient.exe has triggered a breakpoint" arror, and points me to a "lseeki64.c" source file, which I have no idea what is...
I suspect this might have something to do with the fact that DoGATraining is defined as an extern "C":
#define EXPORT __declspec(dllexport)
extern "C" EXPORT int __stdcall DoGATraining(int pPastDataCount, double* pPastData)
Any idea where I might start troubleshooting?
You want an array of 5 doubles, not an array of 5 pointers to double, so change
double* vKaz=(double*)malloc(5*sizeof(double*));
to
double *vKaz = malloc(5 * sizeof(double)); /* don't cast malloc */
or
double *vKaz = malloc(5 * sizeof(*vKaz));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.