comparison src/video/win32/SDL_d3drender.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 f3399f779a1d
comparison
equal deleted inserted replaced
1919:00816063b9c9 1920:8a162bfdc838
237 D3D_RenderData *data; 237 D3D_RenderData *data;
238 HRESULT result; 238 HRESULT result;
239 D3DPRESENT_PARAMETERS pparams; 239 D3DPRESENT_PARAMETERS pparams;
240 IDirect3DSwapChain9 *chain; 240 IDirect3DSwapChain9 *chain;
241 241
242 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer)); 242 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
243 if (!renderer) { 243 if (!renderer) {
244 SDL_OutOfMemory(); 244 SDL_OutOfMemory();
245 return NULL; 245 return NULL;
246 } 246 }
247 SDL_zerop(renderer); 247
248 248 data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
249 data = (D3D_RenderData *) SDL_malloc(sizeof(*data));
250 if (!data) { 249 if (!data) {
251 D3D_DestroyRenderer(renderer); 250 D3D_DestroyRenderer(renderer);
252 SDL_OutOfMemory(); 251 SDL_OutOfMemory();
253 return NULL; 252 return NULL;
254 } 253 }
255 SDL_zerop(data);
256 254
257 renderer->CreateTexture = D3D_CreateTexture; 255 renderer->CreateTexture = D3D_CreateTexture;
258 renderer->SetTexturePalette = D3D_SetTexturePalette; 256 renderer->SetTexturePalette = D3D_SetTexturePalette;
259 renderer->GetTexturePalette = D3D_GetTexturePalette; 257 renderer->GetTexturePalette = D3D_GetTexturePalette;
260 renderer->UpdateTexture = D3D_UpdateTexture; 258 renderer->UpdateTexture = D3D_UpdateTexture;
377 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 375 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
378 D3D_TextureData *data; 376 D3D_TextureData *data;
379 D3DPOOL pool; 377 D3DPOOL pool;
380 HRESULT result; 378 HRESULT result;
381 379
382 data = (D3D_TextureData *) SDL_malloc(sizeof(*data)); 380 data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
383 if (!data) { 381 if (!data) {
384 SDL_OutOfMemory(); 382 SDL_OutOfMemory();
385 return -1; 383 return -1;
386 } 384 }
387 SDL_zerop(data);
388 385
389 texture->driverdata = data; 386 texture->driverdata = data;
390 387
391 if (texture->access == SDL_TextureAccess_Local) { 388 if (texture->access == SDL_TextureAccess_Local) {
392 pool = D3DPOOL_MANAGED; 389 pool = D3DPOOL_MANAGED;