I am working on a 32-bit OSGEarth project, where I have to mosaic a selection of images together into one large image. Switching to 64-bit is not an option.
Images are stored in-memory as a collection of 256x256 tiles. The problem arises when the user attempts to create a single image from many tiles, OSGEarth internally attempts to allocate more memory than a 32-bit system will allow.
I'm attempting to get around this limitation by allocating several chunks of data, each sized 1025 bytes. The 1025'th byte will then "point" to the beginning of the next chunk, with the last byte being a nullptr.
This is what I am currently doing (I plan to allocate much more in the future):
unsigned char* start = new unsigned char[1025];
unsigned char** head = &start;
unsigned char** tail = head + 1025;
for (unsigned int i = 0; i < 3; ++i)
{
auto c = new unsigned char[1025];
*tail = &c[0];
tail = &c + 1025;
}
memset(head, 'C', 1025 * 4);
However, I have some reservations if what I am expecting to happen is actually happening. Is the memory truly allocated in one, contiguous block? If not, then my memset is writing over unallocated data, which could be bad.
Is there any way around the 32-bit limitations?