Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on o…
Browse files Browse the repository at this point in the history
…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 02e111a
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 212 deletions.
2 changes: 1 addition & 1 deletion include/SDL_video.h
Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions src/video/SDL_pixels.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 02e111a

Please sign in to comment.