- updated cmake to check for support of backtraces in gcc compiler
- fixed numerous bugs / warnings from cppcheck
This commit is contained in:
parent
ae91368a99
commit
3b8dd289ac
|
@ -121,6 +121,26 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
||||||
MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur")
|
MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
include(CheckCXXSourceRuns)
|
||||||
|
|
||||||
|
check_cxx_source_runs("
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const size_t max_depth = 6;
|
||||||
|
void *stack_addrs[max_depth];
|
||||||
|
size_t stack_depth = backtrace(stack_addrs, max_depth);
|
||||||
|
}"
|
||||||
|
HAS_GCC_BACKTRACE)
|
||||||
|
|
||||||
|
IF(HAS_GCC_BACKTRACE)
|
||||||
|
message(STATUS "Found GCC backtrace lib, will support backtraces")
|
||||||
|
ADD_DEFINITIONS(-DHAS_GCC_BACKTRACE)
|
||||||
|
ELSE()
|
||||||
|
message(STATUS "**WARNING DID NOT Find GCC backtrace lib")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Debug compiler flags
|
# Debug compiler flags
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ void BattleEnd::render() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Error control = %d for i\n",stats.getControl(i),i);
|
printf("Error control = %d for i = %d\n",stats.getControl(i),i);
|
||||||
assert(false);
|
assert(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2301,7 +2301,7 @@ void runTilesetValidationReport(int argc, char** argv) {
|
||||||
bool showDuplicateFiles = true;
|
bool showDuplicateFiles = true;
|
||||||
bool purgeUnusedFiles = false;
|
bool purgeUnusedFiles = false;
|
||||||
|
|
||||||
double purgedMegaBytes=0;
|
//double purgedMegaBytes=0;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
// Did the user pass a specific tileset to validate?
|
// Did the user pass a specific tileset to validate?
|
||||||
|
|
|
@ -2783,7 +2783,7 @@ void MenuStateConnectedGame::update() {
|
||||||
program->setState(new Game(program, clientInterface->getGameSettings(),false));
|
program->setState(new Game(program, clientInterface->getGameSettings(),false));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3085,7 +3085,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
|
|
||||||
//printf("slot = %d serverInterface->getSlot(i)->getConnectedTime() = %d session key [%d]\n",i,serverInterface->getSlot(i)->getConnectedTime(),serverInterface->getSlot(i)->getSessionKey());
|
//printf("slot = %d serverInterface->getSlot(i)->getConnectedTime() = %d session key [%d]\n",i,serverInterface->getSlot(i)->getConnectedTime(),serverInterface->getSlot(i)->getSessionKey());
|
||||||
|
|
||||||
if(clientConnectedTime == 0 || clientConnectedTime == 0 ||
|
if(clientConnectedTime == 0 ||
|
||||||
(serverInterface->getSlot(i)->getConnectedTime() > 0 && serverInterface->getSlot(i)->getConnectedTime() < clientConnectedTime)) {
|
(serverInterface->getSlot(i)->getConnectedTime() > 0 && serverInterface->getSlot(i)->getConnectedTime() < clientConnectedTime)) {
|
||||||
clientConnectedTime = serverInterface->getSlot(i)->getConnectedTime();
|
clientConnectedTime = serverInterface->getSlot(i)->getConnectedTime();
|
||||||
gameSettings->setMasterserver_admin(serverInterface->getSlot(i)->getSessionKey());
|
gameSettings->setMasterserver_admin(serverInterface->getSlot(i)->getSessionKey());
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ bool MenuStateMasterserver::connectToServer(string ipString, int port) {
|
||||||
showMessageBox(lang.get("Couldnt connect"), lang.get("Connection failed"), false);
|
showMessageBox(lang.get("Couldnt connect"), lang.get("Connection failed"), false);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connection failed\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connection failed\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connected to [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,serverIp.getString().c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connected to [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,serverIp.getString().c_str());
|
||||||
|
|
|
@ -405,7 +405,7 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) {
|
||||||
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
|
||||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[fromPlayerIndex],CODE_AT_LINE_X(fromPlayerIndex));
|
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[fromPlayerIndex],CODE_AT_LINE_X(fromPlayerIndex));
|
||||||
MutexSafeWrapper safeMutexSlot2(slotAccessorMutexes[toPlayerIndex],CODE_AT_LINE_X(toPlayerIndex));
|
MutexSafeWrapper safeMutexSlot2(slotAccessorMutexes[toPlayerIndex],CODE_AT_LINE_X(toPlayerIndex));
|
||||||
if(slots[toPlayerIndex] != NULL && slots[toPlayerIndex] != NULL &&
|
if(slots[toPlayerIndex] != NULL &&
|
||||||
slots[toPlayerIndex]->isConnected() == false) {
|
slots[toPlayerIndex]->isConnected() == false) {
|
||||||
slots[fromPlayerIndex]->setPlayerIndex(toPlayerIndex);
|
slots[fromPlayerIndex]->setPlayerIndex(toPlayerIndex);
|
||||||
slots[toPlayerIndex]->setPlayerIndex(fromPlayerIndex);
|
slots[toPlayerIndex]->setPlayerIndex(fromPlayerIndex);
|
||||||
|
|
|
@ -684,7 +684,7 @@ bool Faction::reqsOk(const RequirableType *rt) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dynamic_cast<const UnitType *>(rt) != NULL ) {
|
if(dynamic_cast<const UnitType *>(rt) != NULL ) {
|
||||||
const UnitType *producedUnitType=(UnitType *) rt;
|
const UnitType *producedUnitType= dynamic_cast<const UnitType *>(rt);
|
||||||
if(producedUnitType != NULL && producedUnitType->getMaxUnitCount() > 0) {
|
if(producedUnitType != NULL && producedUnitType->getMaxUnitCount() > 0) {
|
||||||
if(producedUnitType->getMaxUnitCount() <= getCountForMaxUnitCount(producedUnitType)) {
|
if(producedUnitType->getMaxUnitCount() <= getCountForMaxUnitCount(producedUnitType)) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||||
|
@ -1080,7 +1080,7 @@ void Faction::removeUnit(Unit *unit){
|
||||||
}
|
}
|
||||||
|
|
||||||
throw megaglest_runtime_error("Could not remove unit from faction!");
|
throw megaglest_runtime_error("Could not remove unit from faction!");
|
||||||
assert(false);
|
//assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Faction::addStore(const UnitType *unitType){
|
void Faction::addStore(const UnitType *unitType){
|
||||||
|
|
|
@ -70,7 +70,7 @@ string TechTree::findPath(const string &techName) const{
|
||||||
//printf(">>> test path=%s\n",path.c_str());
|
//printf(">>> test path=%s\n",path.c_str());
|
||||||
if(isdir(path.c_str()) == true) {
|
if(isdir(path.c_str()) == true) {
|
||||||
return path;
|
return path;
|
||||||
break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return "no path found for tech: \""+techname+"\"";
|
//return "no path found for tech: \""+techname+"\"";
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
using Shared::Platform::Mutex;
|
using Shared::Platform::Mutex;
|
||||||
|
|
||||||
// START - For gcc backtrace
|
// START - For gcc backtrace
|
||||||
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -78,7 +79,8 @@ public:
|
||||||
: ptr(ptr), file(file), line(line), bytes(bytes), array(array), freetouse(false), inuse(true), stack(stacktrace) {
|
: ptr(ptr), file(file), line(line), bytes(bytes), array(array), freetouse(false), inuse(true), stack(stacktrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
inline static int getFileAndLine(char *function, void *address, char *file, size_t flen) {
|
inline static int getFileAndLine(char *function, void *address, char *file, size_t flen) {
|
||||||
int line=-1;
|
int line=-1;
|
||||||
if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") {
|
if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") {
|
||||||
|
@ -171,7 +173,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline static string getStackTrace() {
|
inline static string getStackTrace() {
|
||||||
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
if(want_full_leak_stacktrace == true) {
|
if(want_full_leak_stacktrace == true) {
|
||||||
string errMsg = "\nStack Trace:\n";
|
string errMsg = "\nStack Trace:\n";
|
||||||
//errMsg += "To find line #'s use:\n";
|
//errMsg += "To find line #'s use:\n";
|
||||||
|
|
|
@ -547,7 +547,7 @@ int getLastSocketError() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * getLastSocketErrorText(int *errNumber) {
|
const char * getLastSocketErrorText(int *errNumber) {
|
||||||
int errId = (errNumber != NULL ? *errNumber : getLastSocketError());
|
//int errId = (errNumber != NULL ? *errNumber : getLastSocketError());
|
||||||
//return WSAGetLastErrorMessage("",errId);
|
//return WSAGetLastErrorMessage("",errId);
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,15 +326,15 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry
|
||||||
#define CHECK_FONT_PATH(filename,fontFamily) \
|
#define CHECK_FONT_PATH(filename,fontFamily) \
|
||||||
{ \
|
{ \
|
||||||
path = filename; \
|
path = filename; \
|
||||||
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
|
if( font == NULL && path != NULL && strlen(path) > 0 && fileExists(path) == true ) { \
|
||||||
font = strdup(path); \
|
font = strdup(path); \
|
||||||
} \
|
} \
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",path,font); \
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",path,font); \
|
||||||
if( !font && fontFamily != NULL && strlen(fontFamily) > 0) { \
|
if( font != NULL && fontFamily != NULL && strlen(fontFamily) > 0) { \
|
||||||
string fileFound = findFontFamily(font, fontFamily); \
|
string fileFound = findFontFamily(font, fontFamily); \
|
||||||
if(fileFound != "") { \
|
if(fileFound != "") { \
|
||||||
path = fileFound.c_str(); \
|
path = fileFound.c_str(); \
|
||||||
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
|
if( font != NULL && path && strlen(path) > 0 && fileExists(path) == true ) { \
|
||||||
font = strdup(path); \
|
font = strdup(path); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -343,8 +343,8 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry
|
||||||
}
|
}
|
||||||
|
|
||||||
string tryFont = "";
|
string tryFont = "";
|
||||||
if(firstFontToTry || firstFontFamilyToTry) {
|
if(firstFontToTry != NULL || firstFontFamilyToTry != NULL) {
|
||||||
if(firstFontToTry && strlen(firstFontToTry) > 0) {
|
if(firstFontToTry != NULL && strlen(firstFontToTry) > 0) {
|
||||||
tryFont = firstFontToTry;
|
tryFont = firstFontToTry;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
replaceAll(tryFont, "/", "\\");
|
replaceAll(tryFont, "/", "\\");
|
||||||
|
|
|
@ -449,6 +449,7 @@ void PixmapIoPng::openWrite(const string &path, int w, int h, int components) {
|
||||||
void PixmapIoPng::write(uint8 *pixels) {
|
void PixmapIoPng::write(uint8 *pixels) {
|
||||||
|
|
||||||
// initialize stuff
|
// initialize stuff
|
||||||
|
/*
|
||||||
std::auto_ptr<png_byte*> imrow(new png_byte*[h]);
|
std::auto_ptr<png_byte*> imrow(new png_byte*[h]);
|
||||||
for(int i = 0; i < h; ++i) {
|
for(int i = 0; i < h; ++i) {
|
||||||
imrow.get()[i] = pixels+(h-1-i) * w * components;
|
imrow.get()[i] = pixels+(h-1-i) * w * components;
|
||||||
|
@ -470,8 +471,31 @@ void PixmapIoPng::write(uint8 *pixels) {
|
||||||
png_write_info(imgp, infop);
|
png_write_info(imgp, infop);
|
||||||
png_write_image(imgp, imrow.get());
|
png_write_image(imgp, imrow.get());
|
||||||
png_write_end(imgp, NULL);
|
png_write_end(imgp, NULL);
|
||||||
|
*/
|
||||||
|
png_bytep *imrow = new png_bytep[h];
|
||||||
|
//png_bytep *imrow = (png_bytep*) malloc(sizeof(png_bytep) * height);
|
||||||
|
for(int i = 0; i < h; ++i) {
|
||||||
|
imrow[i] = pixels + (h-1-i) * w * components;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_structp imgp = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||||
|
png_infop infop = png_create_info_struct(imgp);
|
||||||
|
png_init_io(imgp, file);
|
||||||
|
|
||||||
|
int color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
if(components == 4) {
|
||||||
|
color_type = PNG_COLOR_TYPE_RGBA;
|
||||||
|
}
|
||||||
|
png_set_IHDR(imgp, infop, w, h,
|
||||||
|
8, color_type, PNG_INTERLACE_NONE,
|
||||||
|
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
|
// write file
|
||||||
|
png_write_info(imgp, infop);
|
||||||
|
png_write_image(imgp, imrow);
|
||||||
|
png_write_end(imgp, NULL);
|
||||||
|
|
||||||
|
delete [] imrow;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Allocate write & info structures
|
// Allocate write & info structures
|
||||||
|
|
|
@ -503,7 +503,7 @@ void MapPreview::reset(int w, int h, float alt, MapSurfaceType surf) {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
|
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
|
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
|
||||||
|
@ -555,7 +555,7 @@ void MapPreview::resize(int w, int h, float alt, MapSurfaceType surf) {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
|
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
|
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
|
||||||
|
|
|
@ -1684,9 +1684,9 @@ bool isKeyDown(int virtualKey) {
|
||||||
|
|
||||||
// kinda hack and wrong...
|
// kinda hack and wrong...
|
||||||
if(key >= 0) {
|
if(key >= 0) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keystate[key] = %d\n",__FILE__,__FUNCTION__,__LINE__,keystate[key]);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keystate[key] = %d\n",__FILE__,__FUNCTION__,__LINE__,keystate[(unsigned char)key]);
|
||||||
|
|
||||||
return (keystate[key] != 0);
|
return (keystate[(unsigned char)key] != 0);
|
||||||
}
|
}
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case vkAdd:
|
case vkAdd:
|
||||||
|
|
|
@ -90,9 +90,12 @@ getHTTPResponse(int s, int * size)
|
||||||
int colon=0;
|
int colon=0;
|
||||||
int valuestart=0;
|
int valuestart=0;
|
||||||
if(header_buf_used + n > header_buf_len) {
|
if(header_buf_used + n > header_buf_len) {
|
||||||
header_buf = realloc(header_buf, header_buf_used + n);
|
char *header_buf_new = realloc(header_buf, header_buf_used + n);
|
||||||
|
if(header_buf_new != NULL) {
|
||||||
|
header_buf = header_buf_new;
|
||||||
header_buf_len = header_buf_used + n;
|
header_buf_len = header_buf_used + n;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
memcpy(header_buf + header_buf_used, buf, n);
|
memcpy(header_buf + header_buf_used, buf, n);
|
||||||
header_buf_used += n;
|
header_buf_used += n;
|
||||||
/* search for CR LF CR LF (end of headers)
|
/* search for CR LF CR LF (end of headers)
|
||||||
|
@ -227,11 +230,15 @@ getHTTPResponse(int s, int * size)
|
||||||
{
|
{
|
||||||
if(content_length >= content_buf_used + (int)bytestocopy) {
|
if(content_length >= content_buf_used + (int)bytestocopy) {
|
||||||
content_buf_len = content_length;
|
content_buf_len = content_length;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
content_buf_len = content_buf_used + (int)bytestocopy;
|
content_buf_len = content_buf_used + (int)bytestocopy;
|
||||||
}
|
}
|
||||||
content_buf = (char *)realloc((void *)content_buf,
|
char *content_buf_new = (char *)realloc((void *)content_buf,
|
||||||
content_buf_len);
|
content_buf_len);
|
||||||
|
if(content_buf_new) {
|
||||||
|
content_buf = content_buf_new;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memcpy(content_buf + content_buf_used, buf + i, bytestocopy);
|
memcpy(content_buf + content_buf_used, buf + i, bytestocopy);
|
||||||
content_buf_used += bytestocopy;
|
content_buf_used += bytestocopy;
|
||||||
|
@ -254,8 +261,11 @@ getHTTPResponse(int s, int * size)
|
||||||
} else {
|
} else {
|
||||||
content_buf_len = content_buf_used + n;
|
content_buf_len = content_buf_used + n;
|
||||||
}
|
}
|
||||||
content_buf = (char *)realloc((void *)content_buf,
|
char *content_buf_new = (char *)realloc((void *)content_buf,
|
||||||
content_buf_len);
|
content_buf_len);
|
||||||
|
if(content_buf_new) {
|
||||||
|
content_buf = content_buf_new;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memcpy(content_buf + content_buf_used, buf, n);
|
memcpy(content_buf + content_buf_used, buf, n);
|
||||||
content_buf_used += n;
|
content_buf_used += n;
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
|
||||||
else if(tryReceiveUntilDataSizeMet == true && bytesReceived < dataSize) {
|
else if(tryReceiveUntilDataSizeMet == true && bytesReceived < dataSize) {
|
||||||
int newBufferSize = (dataSize - bytesReceived);
|
int newBufferSize = (dataSize - bytesReceived);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING, attempting to receive MORE data, bytesReceived = %d, dataSize = %d, newBufferSize = %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,dataSize,newBufferSize);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING, attempting to receive MORE data, bytesReceived = %d, dataSize = %d, newBufferSize = %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,dataSize,newBufferSize);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] WARNING, attempting to receive MORE data, bytesReceived = %d, dataSize = %d, newBufferSize = %d\n",__FILE__,__FUNCTION__,__LINE__,(int)bytesReceived,dataSize,newBufferSize,newBufferSize);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] WARNING, attempting to receive MORE data, bytesReceived = %d, dataSize = %d, newBufferSize = %d\n",__FILE__,__FUNCTION__,__LINE__,(int)bytesReceived,dataSize,newBufferSize);
|
||||||
|
|
||||||
char *dataAsCharPointer = reinterpret_cast<char *>(data);
|
char *dataAsCharPointer = reinterpret_cast<char *>(data);
|
||||||
int additionalBytes = receive(&dataAsCharPointer[bytesReceived], newBufferSize, tryReceiveUntilDataSizeMet);
|
int additionalBytes = receive(&dataAsCharPointer[bytesReceived], newBufferSize, tryReceiveUntilDataSizeMet);
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
// For gcc backtrace on crash!
|
// For gcc backtrace on crash!
|
||||||
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
//#include <mcheck.h>
|
//#include <mcheck.h>
|
||||||
|
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
@ -65,7 +66,8 @@ void exceptionMessage(const exception &excp) {
|
||||||
//int result = MessageBox(NULL, excp.what(), "Error", 0);
|
//int result = MessageBox(NULL, excp.what(), "Error", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
static int getFileAndLine(char *function, void *address, char *file, size_t flen) {
|
static int getFileAndLine(char *function, void *address, char *file, size_t flen) {
|
||||||
int line=-1;
|
int line=-1;
|
||||||
if(PlatformExceptionHandler::application_binary != "") {
|
if(PlatformExceptionHandler::application_binary != "") {
|
||||||
|
@ -160,7 +162,8 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen
|
||||||
|
|
||||||
string PlatformExceptionHandler::getStackTrace() {
|
string PlatformExceptionHandler::getStackTrace() {
|
||||||
string errMsg = "";
|
string errMsg = "";
|
||||||
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
//#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
|
#if defined(HAS_GCC_BACKTRACE)
|
||||||
// if(disableBacktrace == false && sdl_quitCalled == false) {
|
// if(disableBacktrace == false && sdl_quitCalled == false) {
|
||||||
errMsg = "\nStack Trace:\n";
|
errMsg = "\nStack Trace:\n";
|
||||||
//errMsg += "To find line #'s use:\n";
|
//errMsg += "To find line #'s use:\n";
|
||||||
|
|
|
@ -64,7 +64,7 @@ std::string utf8_encode(const std::wstring wstr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert an UTF8 string to a wide Unicode String
|
// Convert an UTF8 string to a wide Unicode String
|
||||||
std::wstring utf8_decode(const std::string str) {
|
std::wstring utf8_decode(const std::string &str) {
|
||||||
string friendly_path = str;
|
string friendly_path = str;
|
||||||
replaceAll(friendly_path, "/", "\\");
|
replaceAll(friendly_path, "/", "\\");
|
||||||
replaceAll(friendly_path, "\\\\", "\\");
|
replaceAll(friendly_path, "\\\\", "\\");
|
||||||
|
|
Loading…
Reference in New Issue