fix string and malloc compilation issues

This commit is contained in:
Josh Holtrop 2011-05-25 16:10:58 -04:00
parent 4349f3f82c
commit 60b1626342

View File

@ -17,10 +17,10 @@ GLuint TextureCache::load(const char *fname)
}
GLuint texture;
SDL_Surface * temp = IMG_Load(filename);
SDL_Surface * temp = IMG_Load(filename.c_str());
if (!temp)
{
fprintf(stderr, "Failed to load image '%s'!\n", filename);
fprintf(stderr, "Failed to load image '%s'!\n", filename.c_str());
return 0;
}
@ -41,11 +41,10 @@ GLuint TextureCache::load(const char *fname)
SDL_FreeSurface(temp);
if (!texsurf)
{
fprintf(stderr, "'%s' was not converted properly!\n", filename);
fprintf(stderr, "'%s' was not converted properly!\n", filename.c_str());
return 0;
}
unsigned int * pixels =
malloc(sizeof(unsigned int) * texsurf->w * texsurf->h);
unsigned int * pixels = new unsigned int[texsurf->w * texsurf->h];
int y;
unsigned int dstOffset = texsurf->w * (texsurf->h - 1);
unsigned int srcOffset = 0;
@ -63,7 +62,7 @@ GLuint TextureCache::load(const char *fname)
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
SDL_FreeSurface(texsurf);
free(pixels);
delete[] pixels;
m_cache[filename] = texture;
return texture;