Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_sw.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 | 092bd3a019c5 |
children | 595ac54a8f9f |
comparison
equal
deleted
inserted
replaced
1919:00816063b9c9 | 1920:8a162bfdc838 |
---|---|
103 static SDL_Texture * | 103 static SDL_Texture * |
104 CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h) | 104 CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h) |
105 { | 105 { |
106 SDL_Texture *texture; | 106 SDL_Texture *texture; |
107 | 107 |
108 texture = (SDL_Texture *) SDL_malloc(sizeof(*texture)); | 108 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); |
109 if (!texture) { | 109 if (!texture) { |
110 SDL_OutOfMemory(); | 110 SDL_OutOfMemory(); |
111 return NULL; | 111 return NULL; |
112 } | 112 } |
113 | 113 |
114 SDL_zerop(texture); | |
115 texture->format = format; | 114 texture->format = format; |
116 texture->access = SDL_TextureAccess_Local; | 115 texture->access = SDL_TextureAccess_Local; |
117 texture->w = w; | 116 texture->w = w; |
118 texture->h = h; | 117 texture->h = h; |
119 texture->renderer = renderer; | 118 texture->renderer = renderer; |
171 if (!renderer) { | 170 if (!renderer) { |
172 SDL_OutOfMemory(); | 171 SDL_OutOfMemory(); |
173 return NULL; | 172 return NULL; |
174 } | 173 } |
175 | 174 |
176 data = (SW_RenderData *) SDL_malloc(sizeof(*data)); | 175 data = (SW_RenderData *) SDL_calloc(1, sizeof(*data)); |
177 if (!data) { | 176 if (!data) { |
178 SW_DestroyRenderer(renderer); | 177 SW_DestroyRenderer(renderer); |
179 SDL_OutOfMemory(); | 178 SDL_OutOfMemory(); |
180 return NULL; | 179 return NULL; |
181 } | 180 } |
182 SDL_zerop(data); | |
183 | 181 |
184 renderer->CreateTexture = SW_CreateTexture; | 182 renderer->CreateTexture = SW_CreateTexture; |
185 renderer->QueryTexturePixels = SW_QueryTexturePixels; | 183 renderer->QueryTexturePixels = SW_QueryTexturePixels; |
186 renderer->SetTexturePalette = SW_SetTexturePalette; | 184 renderer->SetTexturePalette = SW_SetTexturePalette; |
187 renderer->GetTexturePalette = SW_GetTexturePalette; | 185 renderer->GetTexturePalette = SW_GetTexturePalette; |