DarthMike / indielib-crossplatform

IndieLib is a cross-platform Game Graphics engine. Main focus is OpenGL ES 2.0 for mobile iOS operating system, and OpenGL desktop. **NOT SUPPORTED ANYMORE**
zlib License
61 stars 27 forks source link

Windows: Need to fix memory management between DLL and app space #124

Closed DarthMike closed 11 years ago

DarthMike commented 11 years ago

Seems original lib only supported release configurations. This should be fixed by issue #122 work. When lib is built, VC++ links to different C runtime on debug vs release configurations.

There is a potential problem of different runtimes used by app and library. This would normally not happen, but it's a dormant issue, even for app and lib compiled vs debug and release correctly.

Fixing it means not touching memory allocated from app inside the DLL and viceversa. The main point where lib breaks is the entities creation (entity, surface, image...) where user can allocate has he wants (stack or new) and library then owns the reference (!!) this calls for problems when C runtimes differ between built library and app.

We should review all API to ensure no memory is breaking that rule. And refactor code to allow for factory methods to be used when entities from library need to be allocated, and memory would be owned by library. Also no deletion of pointers coming from app should be made inside the app. We need to update:

  1. Library
  2. Tests
  3. Tutorials
  4. Docs
  5. Wiki
DarthMike commented 11 years ago

@M-F-K I'm still working on this, but please could you review changes as they go? It's a delicate matter and I'd like you to check the code for anything suspicious or wrong.

DarthMike commented 11 years ago

Fixed.