1
General / [Solved] Copying sf::Font, sf::SoundBuffer into custom pool allocated memory
« on: January 29, 2017, 10:05:43 am »
I wrote a class for pool allocator and tested it with some basic structs, sf::Texture and it seems to work correctly. However when I use it to copy a sf::Font, sf::SoundBuffer into the allocated block I get the following error:
For sf::Font the size of the class is 76 bytes and alignment is 4 bytes, my allocator is following this and allocating it a block of 76 bytes with 4 byte alignment, I can't figure out how to resolve this error.
Exception thrown at 0x0F19009E (sfml-graphics-d-2.dll) in ChernoGame.exe: 0xC0000005: Access violation writing location 0xCDCDCDCD.
The code that throws this error:ResourceType *newResource = (ResourceType*)allocator.alloc();
ResourceType t;
*newResource = t; //error is thrown from here
When I use this for sf::Texture it works correctly, this error is thrown only when I use sf::Font, sf::SoundBufferResourceType t;
*newResource = t; //error is thrown from here
For sf::Font the size of the class is 76 bytes and alignment is 4 bytes, my allocator is following this and allocating it a block of 76 bytes with 4 byte alignment, I can't figure out how to resolve this error.