- attempt to bugfix windows using proper printf syntax for data types

This commit is contained in:
Mark Vejvoda
2012-11-10 06:37:23 +00:00
parent a43ebdb69e
commit ff58a868b3
28 changed files with 178 additions and 157 deletions

View File

@@ -25,6 +25,27 @@
#endif
#if defined(_MSC_VER)
#define MG_SIZE_T_SPECIFIER "%Iu"
#define MG_SSIZE_T_SPECIFIER "%Id"
#define MG_PTRDIFF_T_SPECIFIER "%Id"
#elif defined(__GNUC__)
#define MG_SIZE_T_SPECIFIER "%zu"
#define MG_SSIZE_T_SPECIFIER "%zd"
#define MG_PTRDIFF_T_SPECIFIER "%zd"
#else
// TODO figure out which to use.
#if NUMBITS == 32
#define MG_SIZE_T_SPECIFIER "%lu"
#define MG_SSIZE_T_SPECIFIER "%ld"
#define MG_PTRDIFF_T_SPECIFIER "%ld"
#else
#define MG_SIZE_T_SPECIFIER "%llu"
#define MG_SSIZE_T_SPECIFIER "%lld"
#define MG_PTRDIFF_T_SPECIFIER "%lld"
#endif
#endif
namespace Shared{ namespace Platform{
#ifndef WIN32

View File

@@ -324,7 +324,7 @@ public:
//if(info.line == 0) return;
MutexSafeWrapper safeMutexMasterList(mutex);
//printf("ALLOCATE.\tfile: %s, line: %d, bytes: %zu, array: %d inuse: %d\n", info.file, info.line, info.bytes, info.array, info.inuse);
//printf("ALLOCATE.\tfile: %s, line: %d, bytes: " MG_SIZE_T_SPECIFIER ", array: %d inuse: %d\n", info.file, info.line, info.bytes, info.array, info.inuse);
if(info.line > 0) {
++allocCount;
@@ -339,7 +339,7 @@ public:
}
}
printf("ALLOCATE NOT MONITORED.\tfile: %s, line: %d, ptr [%p], bytes: %zu, array: %d inuse: %d, \n%s\n", info.file, info.line, info.ptr, info.bytes, info.array, info.inuse, info.stack.c_str());
printf("ALLOCATE NOT MONITORED.\tfile: %s, line: %d, ptr [%p], bytes: " MG_SIZE_T_SPECIFIER ", array: %d inuse: %d, \n%s\n", info.file, info.line, info.ptr, info.bytes, info.array, info.inuse, info.stack.c_str());
++nonMonitoredCount;
nonMonitoredBytes+= info.bytes;

View File

@@ -411,7 +411,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV2), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianMeshHeaderV2(meshHeader);
@@ -489,7 +489,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(vertices, frameCount*vertexCount);
@@ -497,7 +497,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
@@ -506,7 +506,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
if(readBytes != 1 && vertexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec2f>(texCoords, vertexCount);
@@ -514,7 +514,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(&diffuseColor, sizeof(Vec3f), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(&diffuseColor, 1);
@@ -522,7 +522,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(&opacity, sizeof(float32), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
opacity = Shared::PlatformByteOrder::fromCommonEndian(opacity);
@@ -531,7 +531,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
if(readBytes != 1 && indexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,indexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,indexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
Shared::PlatformByteOrder::fromEndianTypeArray<uint32>(indices, indexCount);
@@ -548,7 +548,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV3), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianMeshHeaderV3(meshHeader);
@@ -623,7 +623,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(vertices, frameCount*vertexCount);
@@ -631,7 +631,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
@@ -641,7 +641,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
if(readBytes != 1 && vertexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec2f>(texCoords, vertexCount);
@@ -650,7 +650,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(&diffuseColor, sizeof(Vec3f), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(&diffuseColor, 1);
@@ -658,7 +658,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(&opacity, sizeof(float32), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
opacity = Shared::PlatformByteOrder::fromCommonEndian(opacity);
@@ -667,7 +667,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
if(readBytes != 1 && indexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,indexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,indexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
Shared::PlatformByteOrder::fromEndianTypeArray<uint32>(indices, indexCount);
@@ -735,7 +735,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
size_t readBytes = fread(&meshHeader, sizeof(MeshHeader), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianMeshHeader(meshHeader);
@@ -774,7 +774,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
readBytes = fread(cMapPath, mapPathSize, 1, f);
if(readBytes != 1 && mapPathSize != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,mapPathSize,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,mapPathSize,__LINE__);
throw megaglest_runtime_error(szBuf);
}
Shared::PlatformByteOrder::fromEndianTypeArray<uint8>(cMapPath, mapPathSize);
@@ -800,7 +800,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
readBytes = fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(vertices, frameCount*vertexCount);
@@ -808,7 +808,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
readBytes = fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(readBytes != 1 && (frameCount * vertexCount) != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
@@ -817,7 +817,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
if(readBytes != 1 && vertexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u][%u] on line: %d.",readBytes,frameCount,vertexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianVecArray<Vec2f>(texCoords, vertexCount);
@@ -825,7 +825,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
if(readBytes != 1 && indexCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,indexCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,indexCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
Shared::PlatformByteOrder::fromEndianTypeArray<uint32>(indices, indexCount);
@@ -1168,7 +1168,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
if(readBytes != 1) {
fclose(f);
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianFileHeader(fileHeader);
@@ -1190,7 +1190,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
readBytes = fread(&modelHeader, sizeof(ModelHeader), 1, f);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianModelHeader(modelHeader);
@@ -1224,7 +1224,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
if(readBytes != 1 && meshCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,meshCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,meshCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
meshCount = Shared::PlatformByteOrder::fromCommonEndian(meshCount);
@@ -1251,7 +1251,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
if(readBytes != 1 && meshCount != 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu [%u] on line: %d.",readBytes,meshCount,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " [%u] on line: %d.",readBytes,meshCount,__LINE__);
throw megaglest_runtime_error(szBuf);
}
meshCount = Shared::PlatformByteOrder::fromCommonEndian(meshCount);

View File

@@ -122,7 +122,7 @@ void PixmapIoTga::openRead(const string &path) {
size_t readBytes = fread(&fileHeader, sizeof(TargaFileHeader), 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
@@ -171,7 +171,7 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
size_t readBytes = fread(&l, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -186,7 +186,7 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
size_t readBytes = fread(&b, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -196,7 +196,7 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
readBytes = fread(&g, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -206,7 +206,7 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
readBytes = fread(&r, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -217,7 +217,7 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
readBytes = fread(&a, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -346,7 +346,7 @@ void PixmapIoBmp::openRead(const string &path){
size_t readBytes = fread(&fileHeader, sizeof(BitmapFileHeader), 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
@@ -368,7 +368,7 @@ void PixmapIoBmp::openRead(const string &path){
readBytes = fread(&infoHeader, sizeof(BitmapInfoHeader), 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -405,7 +405,7 @@ void PixmapIoBmp::read(uint8 *pixels, int components) {
size_t readBytes = fread(&b, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -414,7 +414,7 @@ void PixmapIoBmp::read(uint8 *pixels, int components) {
readBytes = fread(&g, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {
@@ -424,7 +424,7 @@ void PixmapIoBmp::read(uint8 *pixels, int components) {
readBytes = fread(&r, 1, 1, file);
if(readBytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",readBytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
if(bigEndianSystem == true) {

View File

@@ -795,7 +795,7 @@ void MapPreview::loadFromFile(const string &path) {
size_t bytes = fread(&header, sizeof(MapFileHeader), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
fromEndianMapFileHeader(header);
@@ -820,7 +820,7 @@ void MapPreview::loadFromFile(const string &path) {
bytes = fread(&startLocations[i].x, sizeof(int32), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
startLocations[i].x = Shared::PlatformByteOrder::fromCommonEndian(startLocations[i].x);
@@ -828,7 +828,7 @@ void MapPreview::loadFromFile(const string &path) {
bytes = fread(&startLocations[i].y, sizeof(int32), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
startLocations[i].y = Shared::PlatformByteOrder::fromCommonEndian(startLocations[i].y);
@@ -841,7 +841,7 @@ void MapPreview::loadFromFile(const string &path) {
bytes = fread(&cells[i][j].height, sizeof(float), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
cells[i][j].height = Shared::PlatformByteOrder::fromCommonEndian(cells[i][j].height);
@@ -854,7 +854,7 @@ void MapPreview::loadFromFile(const string &path) {
bytes = fread(&cells[i][j].surface, sizeof(int8), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
cells[i][j].surface = Shared::PlatformByteOrder::fromCommonEndian(cells[i][j].surface);
@@ -868,7 +868,7 @@ void MapPreview::loadFromFile(const string &path) {
bytes = fread(&obj, sizeof(int8), 1, f1);
if(bytes != 1) {
char szBuf[8096]="";
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
snprintf(szBuf,8096,"fread returned wrong size = " MG_SIZE_T_SPECIFIER " on line: %d.",bytes,__LINE__);
throw megaglest_runtime_error(szBuf);
}
obj = Shared::PlatformByteOrder::fromCommonEndian(obj);
@@ -1056,7 +1056,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
if(errorOnInvalidMap == true) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nfile [%s]\nreadBytes != sizeof(MapFileHeader) [%zu] [%zu]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str(),readBytes,sizeof(MapFileHeader));
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nfile [%s]\nreadBytes != sizeof(MapFileHeader) [" MG_SIZE_T_SPECIFIER "] [" MG_SIZE_T_SPECIFIER "]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str(),readBytes,sizeof(MapFileHeader));
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
throw megaglest_runtime_error(szBuf);

View File

@@ -108,9 +108,9 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
size_t result = fwrite(buffer, size, nmemb, out->stream);
if(result != nmemb) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %zu, result = %zu\n",fullFilePath.c_str(),nmemb,result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %zu, result = %zu\n",fullFilePath.c_str(),nmemb,result);
SystemFlags::OutputDebug(SystemFlags::debugError,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %zu, result = %zu\n",fullFilePath.c_str(),nmemb,result);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = " MG_SIZE_T_SPECIFIER ", result = " MG_SIZE_T_SPECIFIER "\n",fullFilePath.c_str(),nmemb,result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = " MG_SIZE_T_SPECIFIER ", result = " MG_SIZE_T_SPECIFIER "\n",fullFilePath.c_str(),nmemb,result);
SystemFlags::OutputDebug(SystemFlags::debugError,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = " MG_SIZE_T_SPECIFIER ", result = " MG_SIZE_T_SPECIFIER "\n",fullFilePath.c_str(),nmemb,result);
//return -1; /* failure, can't open file to write */
}
return result;

View File

@@ -1170,12 +1170,12 @@ int Socket::getDataToRead(bool wantImmediateReply) {
break;
}
else if(hasDataToRead() == true) {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, (hasDataToRead() == true) err = %d, sock = %d, size = %zu, loopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size,loopCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, (hasDataToRead() == true) err = %d, sock = %d, size = %zu\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, (hasDataToRead() == true) err = %d, sock = %d, size = " MG_SIZE_T_SPECIFIER ", loopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size,loopCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, (hasDataToRead() == true) err = %d, sock = %d, size = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size);
}
else {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, err = %d, sock = %d, size = %zu, loopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size,loopCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, err = %d, sock = %d, size = %zu\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, err = %d, sock = %d, size = " MG_SIZE_T_SPECIFIER ", loopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size,loopCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING PEEKING SOCKET DATA, err = %d, sock = %d, size = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,err,sock,size);
break;
}

View File

@@ -575,7 +575,7 @@ StaticSoundSource* SoundPlayerOpenAL::findStaticSoundSource() {
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] playingCount = %d, staticSources.size() = %zu, params.staticBufferCount = %u\n",__FILE__,__FUNCTION__,__LINE__,playingCount,(unsigned long)staticSources.size(),params.staticBufferCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] playingCount = %d, staticSources.size() = " MG_SIZE_T_SPECIFIER ", params.staticBufferCount = %u\n",__FILE__,__FUNCTION__,__LINE__,playingCount,(unsigned long)staticSources.size(),params.staticBufferCount);
// create a new source
if(staticSources.size() >= params.staticBufferCount) {

View File

@@ -227,7 +227,7 @@ void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
uint32 samples = static_cast<uint32>(ov_pcm_total(vf, -1));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld, samples = %zu\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window,samples);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld, samples = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window,samples);
soundInfo->setChannels(vi->channels);
soundInfo->setsamplesPerSecond(vi->rate);

View File

@@ -54,21 +54,21 @@ void AllocRegistry::dump(const char *path) {
leakBytes += info.bytes;
//allocs[i].stack = AllocInfo::getStackTrace();
fprintf(f, "Leak #%d.\tfile: %s, line: %d, ptr [%p], bytes: %zu, array: %d, inuse: %d\n%s\n", ++leakCount, info.file, info.line, info.ptr, info.bytes, info.array,info.inuse,info.stack.c_str());
fprintf(f, "Leak #%d.\tfile: %s, line: %d, ptr [%p], bytes: " MG_SIZE_T_SPECIFIER ", array: %d, inuse: %d\n%s\n", ++leakCount, info.file, info.line, info.ptr, info.bytes, info.array,info.inuse,info.stack.c_str());
}
}
}
fprintf(f, "\nTotal leaks: %d, %zu bytes\n", leakCount, leakBytes);
fprintf(f, "Total allocations: %d, %zu bytes\n", allocCount, allocBytes);
fprintf(f, "Not monitored allocations: %d, %zu bytes\n", nonMonitoredCount, nonMonitoredBytes);
fprintf(f, "\nTotal leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
fprintf(f, "Total allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", allocCount, allocBytes);
fprintf(f, "Not monitored allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", nonMonitoredCount, nonMonitoredBytes);
fclose(f);
printf("Memory leak dump summary at: %s\n",szBuf2);
printf("Total leaks: %d, %zu bytes\n", leakCount, leakBytes);
printf("Total allocations: %d, %zu bytes\n", allocCount, allocBytes);
printf("Not monitored allocations: %d, %zu bytes\n", nonMonitoredCount, nonMonitoredBytes);
printf("Total leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
printf("Total allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", allocCount, allocBytes);
printf("Not monitored allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", nonMonitoredCount, nonMonitoredBytes);
}
#endif