Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on o…

…perating systems which map the zero page for memory allocations.

OpenGL renderer in progress
  • Loading branch information
slouken committed Jul 22, 2006
1 parent 29ed2e5 commit 02e111ad0652df48629c32e37dc51237c6cb4f81
@@ -191,7 +191,7 @@ typedef struct SDL_RendererInfo
Uint32 blend_modes; /**< A mask of supported blend modes */
Uint32 scale_modes; /**< A mask of supported scale modes */
Uint32 num_texture_formats; /**< The number of available texture formats */
Uint32 texture_formats[16]; /**< The available texture formats */
Uint32 texture_formats[20]; /**< The available texture formats */
int max_texture_width; /**< The maximimum texture width */
int max_texture_height; /**< The maximimum texture height */
} SDL_RendererInfo;
@@ -346,12 +346,11 @@ SDL_AllocFormat(int bpp,
Uint32 mask;

/* Allocate an empty pixel format structure */
format = SDL_malloc(sizeof(*format));
format = SDL_calloc(1, sizeof(*format));
if (format == NULL) {
SDL_OutOfMemory();
return (NULL);
}
SDL_memset(format, 0, sizeof(*format));
format->alpha = SDL_ALPHA_OPAQUE;

/* Set up the format */
@@ -714,22 +713,20 @@ SDL_AllocBlitMap(void)
SDL_BlitMap *map;

/* Allocate the empty map */
map = (SDL_BlitMap *) SDL_malloc(sizeof(*map));
map = (SDL_BlitMap *) SDL_calloc(1, sizeof(*map));
if (map == NULL) {
SDL_OutOfMemory();
return (NULL);
}
SDL_memset(map, 0, sizeof(*map));

/* Allocate the software blit data */
map->sw_data =
(struct private_swaccel *) SDL_malloc(sizeof(*map->sw_data));
(struct private_swaccel *) SDL_calloc(1, sizeof(*map->sw_data));
if (map->sw_data == NULL) {
SDL_FreeBlitMap(map);
SDL_OutOfMemory();
return (NULL);
}
SDL_memset(map->sw_data, 0, sizeof(*map->sw_data));

/* It's ready to go */
return (map);

0 comments on commit 02e111a

Please sign in to comment.