comparison src/video/SDL_surface.c @ 1920:8a162bfdc838

Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations. OpenGL renderer in progress
author Sam Lantinga <slouken@libsdl.org>
date Sat, 22 Jul 2006 08:33:18 +0000
parents c121d94672cb
children 926294b2bb4e
comparison
equal deleted inserted replaced
1919:00816063b9c9 1920:8a162bfdc838
40 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) 40 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
41 { 41 {
42 SDL_Surface *surface; 42 SDL_Surface *surface;
43 43
44 /* Allocate the surface */ 44 /* Allocate the surface */
45 surface = (SDL_Surface *) SDL_malloc(sizeof(*surface)); 45 surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
46 if (surface == NULL) { 46 if (surface == NULL) {
47 SDL_OutOfMemory(); 47 SDL_OutOfMemory();
48 return NULL; 48 return NULL;
49 } 49 }
50 SDL_zerop(surface);
51 50
52 surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); 51 surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
53 if (!surface->format) { 52 if (!surface->format) {
54 SDL_FreeSurface(surface); 53 SDL_FreeSurface(surface);
55 return NULL; 54 return NULL;