I now know what the problem is, but I don't know how to fix it. To help, I've reposted the code below (the top part is the function itself with the key area in focus and the bottom is how the function is used:
Here's what the parameters mean:Code:char LoadFile(const char FileName[64], char FileType, BITMAPINFOHEADER *BMPInfo, unsigned char *BMPData, char FogUsed, double ObjectScaling, char LoadType, unsigned char *BMPDataPointer, unsigned long BMPMemoryUsage)
{
...
BMPMemoryUsage = BMPInfo->biWidth*BMPInfo->biHeight*3;
BMPDataPointer = malloc(BMPMemoryUsage);
fread(BMPData, 1, BMPMemoryUsage, FileHandle); // read the main image data // reads in BGR format
DebugPointerTest[1] = (int)BMPDataPointer;
DebugTest[2] = (double)BMPMemoryUsage; // works fine, but the actual focused one is unchanged
DebugTest[3] = (double)DebugPointerTest[1]; // shows 0 - invalid pointer
...
}
...
PrelakeHills04MainDataPointer = PrelakeHills04Data; // an array so the "&" isn't needed
LoadFile("PrelakeHills04.tga", 2, &PrelakeHills04Info, PrelakeHills04Data, 1, PrelakeHills04.Scaling, 0, PrelakeHills04MainDataPointer, PrelakeHills04MemoryUsage);
Filename - the file name - no problems
FileType - a "flag" to let me know whether I'm loading a BMP or TGA file so it reads the header data properly - no problems
BMPInfo - a pointer to the info structure - no problems
BMPData - a pointer to the image data - no problems
FogUsed - a flag to indicate whether or not fog needs to added to the object (not everything uses it, such as texts, panels, etc.) - no problems
ObjectScaling - the object's distance, which determines the fog's intensity - no problems
LoadType - a "flag" to indicate the type of load to do - a full load (done at startup) or a reload (rarely used, but generally to reapply fog after adjusting the visiblity) - no problems
BMPDataPointer - a pointer to the data, of which I'm trying to use to get malloc to work - having problems
BMPMemoryUsage - used to set the "memory usage" amount for the item - having problems
I'd otherwise have 3 more parameters, but were left out since I couldn't seem to set pointers through a function call (not returning pointers, setting them).