Permalink
Browse files

attempt to get rid of calloc

  • Loading branch information...
Keruspe committed Jul 1, 2010
1 parent ee872c0 commit 5ac64c8638412189ea559cd8b3621a0fc9c01ff7
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/display/display.cpp
View
@@ -43,7 +43,7 @@ int Display::heightMax = 0;
int Display::width = 0;
int Display::height = 0;
std::map< SDL_Surface *, void * > Display::buffers;
std::map< SDL_Surface *, unsigned char * > Display::buffers;
SDL_Surface * Display::sBackground = NULL;
@@ -135,11 +135,10 @@ Display::svgToSurface(std::string file, Uint32 targetWidth, Uint32 targetHeight)
double sH = static_cast< double >(targetHeight) / static_cast< double >(dims.height);
Uint32 stride = 4 * targetWidth;
void * buffer = calloc(stride * targetHeight, 1);
unsigned char * buffer = new unsigned char[stride * targetHeight];
cairo_surface_t * cSurface = cairo_image_surface_create_for_data(
static_cast< unsigned char * >(buffer),
CAIRO_FORMAT_ARGB32, targetWidth, targetHeight, stride);
buffer, CAIRO_FORMAT_ARGB32, targetWidth, targetHeight, stride);
cairo_t * cObject = cairo_create(cSurface);
cairo_scale(cObject, sW, sH);
@@ -240,10 +239,10 @@ Display::cleanSurface(SDL_Surface * & surf)
{
if ( surf )
{
std::map< SDL_Surface *, void * >::iterator i = buffers.find(surf);
std::map< SDL_Surface *, unsigned char * >::iterator i = buffers.find(surf);
if ( i != buffers.end() )
{
free(i->second);
delete[] i->second;
buffers.erase(i);
}
SDL_FreeSurface(surf);

0 comments on commit 5ac64c8

Please sign in to comment.