mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 02:40:17 +02:00
- memory leak fixes
This commit is contained in:
@@ -71,7 +71,7 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
||||
return NULL;
|
||||
}
|
||||
is.seekg(0, ios::beg);
|
||||
uint8 * buffer = new uint8[length];
|
||||
uint8 *buffer = new uint8[length];
|
||||
is.read((char*)buffer, length);
|
||||
//Check buffer (weak jpeg check)
|
||||
//if (buffer[0] != 0x46 || buffer[1] != 0xA0) {
|
||||
@@ -209,6 +209,9 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
||||
jpeg_finish_decompress( &cinfo );
|
||||
jpeg_destroy_decompress( &cinfo );
|
||||
delete[] row_pointer[0];
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -947,6 +947,11 @@ void ParticleManager::update(int renderFps) {
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld, particleSystemCount = %d, particleCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),particleSystemCount,particleCount);
|
||||
}
|
||||
|
||||
bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particleSystem) const {
|
||||
int index = findParticleSystems(particleSystem, this->particleSystems);
|
||||
return (index >= 0);
|
||||
}
|
||||
|
||||
int ParticleManager::findParticleSystems(ParticleSystem *psFind, const vector<ParticleSystem *> &particleSystems) const {
|
||||
int result = -1;
|
||||
for (int i = 0; i < particleSystems.size(); i++) {
|
||||
|
@@ -626,7 +626,7 @@ std::vector<std::string> Socket::getLocalIPAddressList() {
|
||||
}
|
||||
ipIdx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
@@ -662,21 +662,26 @@ std::vector<std::string> Socket::getLocalIPAddressList() {
|
||||
strncpy(ifrA.ifr_name, szBuf, maxIfNameLength);
|
||||
ifrA.ifr_name[maxIfNameLength] = '\0';
|
||||
|
||||
ioctl(fd, SIOCGIFADDR, &ifr);
|
||||
int result_ifaddrr = ioctl(fd, SIOCGIFADDR, &ifr);
|
||||
ioctl(fd, SIOCGIFFLAGS, &ifrA);
|
||||
close(fd);
|
||||
|
||||
sprintf(myhostaddr, "%s",inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] szBuf [%s], myhostaddr = [%s], ifr.ifr_flags = %d, ifrA.ifr_flags = %d, ifr.ifr_name [%s]\n",__FILE__,__FUNCTION__,__LINE__,szBuf,myhostaddr,ifr.ifr_flags,ifrA.ifr_flags,ifr.ifr_name);
|
||||
if(result_ifaddrr >= 0) {
|
||||
struct sockaddr_in *pSockAddr = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
if(pSockAddr != NULL) {
|
||||
sprintf(myhostaddr, "%s",inet_ntoa(pSockAddr->sin_addr));
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] szBuf [%s], myhostaddr = [%s], ifr.ifr_flags = %d, ifrA.ifr_flags = %d, ifr.ifr_name [%s]\n",__FILE__,__FUNCTION__,__LINE__,szBuf,myhostaddr,ifr.ifr_flags,ifrA.ifr_flags,ifr.ifr_name);
|
||||
|
||||
// Now only include interfaces that are both UP and running
|
||||
if( (ifrA.ifr_flags & IFF_UP) == IFF_UP &&
|
||||
(ifrA.ifr_flags & IFF_RUNNING) == IFF_RUNNING) {
|
||||
if( strlen(myhostaddr) > 0 &&
|
||||
strncmp(myhostaddr,"127.",4) != 0 &&
|
||||
strncmp(myhostaddr,"0.",2) != 0) {
|
||||
if(std::find(ipList.begin(),ipList.end(),myhostaddr) == ipList.end()) {
|
||||
ipList.push_back(myhostaddr);
|
||||
// Now only include interfaces that are both UP and running
|
||||
if( (ifrA.ifr_flags & IFF_UP) == IFF_UP &&
|
||||
(ifrA.ifr_flags & IFF_RUNNING) == IFF_RUNNING) {
|
||||
if( strlen(myhostaddr) > 0 &&
|
||||
strncmp(myhostaddr,"127.",4) != 0 &&
|
||||
strncmp(myhostaddr,"0.",2) != 0) {
|
||||
if(std::find(ipList.begin(),ipList.end(),myhostaddr) == ipList.end()) {
|
||||
ipList.push_back(myhostaddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,21 @@ namespace Shared{ namespace Platform{
|
||||
// ======================================
|
||||
// class PlatformContextGl
|
||||
// ======================================
|
||||
PlatformContextGl::PlatformContextGl() {
|
||||
icon = NULL;
|
||||
screen = NULL;
|
||||
}
|
||||
|
||||
PlatformContextGl::~PlatformContextGl() {
|
||||
if(icon != NULL) {
|
||||
SDL_FreeSurface(icon);
|
||||
icon = NULL;
|
||||
}
|
||||
if(screen != NULL) {
|
||||
SDL_FreeSurface(screen);
|
||||
screen = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing) {
|
||||
|
||||
@@ -59,7 +74,13 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
|
||||
|
||||
#ifndef WIN32
|
||||
if(fileExists("megaglest.bmp")) {
|
||||
SDL_Surface *icon = SDL_LoadBMP("megaglest.bmp");
|
||||
|
||||
if(icon != NULL) {
|
||||
SDL_FreeSurface(icon);
|
||||
icon = NULL;
|
||||
}
|
||||
|
||||
icon = SDL_LoadBMP("megaglest.bmp");
|
||||
//SDL_Surface *icon = IMG_Load("megaglest.ico");
|
||||
|
||||
|
||||
@@ -84,7 +105,12 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",__FILE__,__FUNCTION__,__LINE__,resW,resH,colorBits);
|
||||
|
||||
SDL_Surface* screen = SDL_SetVideoMode(resW, resH, colorBits, flags);
|
||||
if(screen != NULL) {
|
||||
SDL_FreeSurface(screen);
|
||||
screen = NULL;
|
||||
}
|
||||
|
||||
screen = SDL_SetVideoMode(resW, resH, colorBits, flags);
|
||||
if(screen == 0) {
|
||||
std::ostringstream msg;
|
||||
msg << "Couldn't set video mode "
|
||||
|
Reference in New Issue
Block a user