Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DLL hell. please help!

DLL hell. please help!

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingdata-structuresperformancequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    will1383
    wrote on last edited by
    #1

    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

    T D 2 Replies Last reply
    0
    • W will1383

      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

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      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. ***

      1 Reply Last reply
      0
      • W will1383

        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

        D Offline
        D Offline
        Dimitri Rochette
        wrote on last edited by
        #3

        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 ).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups