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

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401965
This commit is contained in:
Sam Lantinga 2006-07-22 08:33:18 +00:00
parent 2b538200ba
commit 2fe561616a
9 changed files with 218 additions and 212 deletions

View file

@ -105,13 +105,12 @@ CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
{
SDL_Texture *texture;
texture = (SDL_Texture *) SDL_malloc(sizeof(*texture));
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
if (!texture) {
SDL_OutOfMemory();
return NULL;
}
SDL_zerop(texture);
texture->format = format;
texture->access = SDL_TextureAccess_Local;
texture->w = w;
@ -173,13 +172,12 @@ SW_CreateRenderer(SDL_Window * window, Uint32 flags)
return NULL;
}
data = (SW_RenderData *) SDL_malloc(sizeof(*data));
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
if (!data) {
SW_DestroyRenderer(renderer);
SDL_OutOfMemory();
return NULL;
}
SDL_zerop(data);
renderer->CreateTexture = SW_CreateTexture;
renderer->QueryTexturePixels = SW_QueryTexturePixels;