DLL hell. please help!
-
I have written a dll that acts as a central location for a specific data set. I've set the following declaration: #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif My problem is this. I have an array of data that is built and maintained within the DLL. I have a function that returns a pointer to that data set (array). Upon shutdown of the application, I get the following error: "dbgheap.c line 1011 _CrtIsValidHeapPoint, or an error accessing the heap" The trace in debug dumps this: "Heap Block at c50038 modified at c572e0 past requested size of 72a0" What I believe is happening is the application tries to clean up, but the memory for this data pointer I have is located in the DLL heap, i.e., not local to the app, causing this error. I thought I could just free the point in the application and all would be fine, but this is not working at all. Any suggestions? I have no idea on this one. I thought it might be how I'm declaring the function, or dll as stated above, but that doesn't fix the issue. Any help is GREATLY Appreciated as I am really lost here.:confused: Thanks. Dan
-
I have written a dll that acts as a central location for a specific data set. I've set the following declaration: #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif My problem is this. I have an array of data that is built and maintained within the DLL. I have a function that returns a pointer to that data set (array). Upon shutdown of the application, I get the following error: "dbgheap.c line 1011 _CrtIsValidHeapPoint, or an error accessing the heap" The trace in debug dumps this: "Heap Block at c50038 modified at c572e0 past requested size of 72a0" What I believe is happening is the application tries to clean up, but the memory for this data pointer I have is located in the DLL heap, i.e., not local to the app, causing this error. I thought I could just free the point in the application and all would be fine, but this is not working at all. Any suggestions? I have no idea on this one. I thought it might be how I'm declaring the function, or dll as stated above, but that doesn't fix the issue. Any help is GREATLY Appreciated as I am really lost here.:confused: Thanks. Dan
It seems that you're freeing blocks allocated on another heap. Are you using C runtime in static library? Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
-
I have written a dll that acts as a central location for a specific data set. I've set the following declaration: #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif My problem is this. I have an array of data that is built and maintained within the DLL. I have a function that returns a pointer to that data set (array). Upon shutdown of the application, I get the following error: "dbgheap.c line 1011 _CrtIsValidHeapPoint, or an error accessing the heap" The trace in debug dumps this: "Heap Block at c50038 modified at c572e0 past requested size of 72a0" What I believe is happening is the application tries to clean up, but the memory for this data pointer I have is located in the DLL heap, i.e., not local to the app, causing this error. I thought I could just free the point in the application and all would be fine, but this is not working at all. Any suggestions? I have no idea on this one. I thought it might be how I'm declaring the function, or dll as stated above, but that doesn't fix the issue. Any help is GREATLY Appreciated as I am really lost here.:confused: Thanks. Dan
If you want to allocate memory in a Dll and free this memory elsewhere you can use a GlobalAlloc / GlobalFree ( with the GMEM_FIXED flag you only have to change the alloc and the free lines ).