diff --git a/TextureCache.cc b/TextureCache.cc index f6452c5..5a1cba7 100644 --- a/TextureCache.cc +++ b/TextureCache.cc @@ -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;