I'm attempting to integrate CEGUI into some of my example code for the Oculus Rift. However, I already have my own resource management setup and want to allow CEGUI to use it by creating a custom ResourceProvider. But I'm running to a bit of a problem with memory allocation and deallocation. The problem is that I'm using the CEGUI dynamic library build, but the resource manager I'm creating is inside my own executable.
When I implement *void ResourceProvider::loadRawDataContainer(const CEGUI::String& filename, CEGUI::RawDataContainer& output, const CEGUI::String& resourceGroup)* I have to allocate the buffer which will be assigned to the output container. However, the memory will be deallocated inside the CEGUI DLL when the container is destroyed, which results in a crash if my application and CEGUI are built with different C runtimes.
I can get around this by building with CEGUI_CUSTOM_ALLOCATORS, which allows me to then allocate the memory via CEGUI::RawDataContainer::Allocator, but this solution is less than ideal (and also, CEGUI_CUSTOM_ALLOCATORS doesn't build out of the box on OSX/Xcode, latest version).
A quick solution would be to add a RawDataContainer::allocate(size_t s) method so that I could force the allocation to the CEGUI side of the DLL, regardless of whether I set CEGUI_CUSTOM_ALLOCATORS. In point of fact, since RawDataContainer takes responsibility for deleting the allocated memory in its release() method, I would suggest removing setData() altogether and forcing the use of the propose allocate() method so that RawDataContainer can't attempt to deallocate memory it doesn't own.
Memory allocation issue with custom resource manager
Moderators: CEGUI MVP, CEGUI Team
Re: Memory allocation issue with custom resource manager
Why do you build your application with a different C runtime than you built CEGUI? This does not seem like a good idea in any case. Is there a good reason you need to do it this way?
CrazyEddie: "I don't like GUIs"
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 5 guests