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. ATL / WTL / STL
  4. Container & Dll

Container & Dll

Scheduled Pinned Locked Moved ATL / WTL / STL
dockerperformancequestion
3 Posts 2 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.
  • B Offline
    B Offline
    Bernhard
    wrote on last edited by
    #1

    I've tried to make a Win32 Dll and pass around std::string's (they get filled in the dll and passed back to the calling process) The next step would be to pass a map to the dll, it gets filled there.. and the map is passed back to the caller. It looks like it doesn't work.. the data is passed around nicely.. but when the caller's var's are about to get deleted, it says that the memory was not allocated by this process (which is obvious) Is there any workaround ?


    "I'm from the South Bronx, and I don't care what you say: those cows look dangerous."
    U.S. Secretary of State Colin Powell at George Bush's ranch in Texas

    G 1 Reply Last reply
    0
    • B Bernhard

      I've tried to make a Win32 Dll and pass around std::string's (they get filled in the dll and passed back to the calling process) The next step would be to pass a map to the dll, it gets filled there.. and the map is passed back to the caller. It looks like it doesn't work.. the data is passed around nicely.. but when the caller's var's are about to get deleted, it says that the memory was not allocated by this process (which is obvious) Is there any workaround ?


      "I'm from the South Bronx, and I don't care what you say: those cows look dangerous."
      U.S. Secretary of State Colin Powell at George Bush's ranch in Texas

      G Offline
      G Offline
      geo_m
      wrote on last edited by
      #2

      Don't know from the description if it is exacly your problem, but normally you have to free the memory in the same module you allocated it - therefore if you make 'malloc/new' in a dll you have to call the 'free/delete' in the same dll as well - this is because the exe and dll have different heaps - therefore if you allocate the memory at say 0xabcdabcd in dll and try to free it in exe module, he cannot find it. Solution is to: - either allocate it in exe and ask dll to fill it, then free it in exe (or vice versa for dll) - make some reference counting that will cause that delete is called in a correct module (like com does it when last reference is released) if you need more details, and if this describes the problem you have, don't worry to ask ;-)

      B 1 Reply Last reply
      0
      • G geo_m

        Don't know from the description if it is exacly your problem, but normally you have to free the memory in the same module you allocated it - therefore if you make 'malloc/new' in a dll you have to call the 'free/delete' in the same dll as well - this is because the exe and dll have different heaps - therefore if you allocate the memory at say 0xabcdabcd in dll and try to free it in exe module, he cannot find it. Solution is to: - either allocate it in exe and ask dll to fill it, then free it in exe (or vice versa for dll) - make some reference counting that will cause that delete is called in a correct module (like com does it when last reference is released) if you need more details, and if this describes the problem you have, don't worry to ask ;-)

        B Offline
        B Offline
        Bernhard
        wrote on last edited by
        #3

        Sorry for my late answer.. but i couldn't access CodeProject yesterday. (404) Well.. the answer you've provided is exactly what i thought. The problem is.. i use the standard STL - Containers, and i just wanted to make sure, that i can't pass them around (exe -> dll -> exe) Thanks for your help, Bernhard


        "I'm from the South Bronx, and I don't care what you say: those cows look dangerous."
        U.S. Secretary of State Colin Powell at George Bush's ranch in Texas

        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