Browse code

Replaced malloc and manual initialization with calloc

Andrew Alderwick authored on 18/09/2021 21:34:13
Showing 1 changed files
... ...
@@ -187,7 +187,6 @@ quit(void)
187 187
 static int
188 188
 init(void)
189 189
 {
190
-	int i;
191 190
 	SDL_AudioSpec as;
192 191
 	SDL_zero(as);
193 192
 	as.freq = SAMPLE_FREQUENCY;
... ...
@@ -217,10 +216,8 @@ init(void)
217 216
 	gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, ppu.width + PAD * 2, ppu.height + PAD * 2);
218 217
 	if(gTexture == NULL || SDL_SetTextureBlendMode(gTexture, SDL_BLENDMODE_NONE))
219 218
 		return error("sdl_texture", SDL_GetError());
220
-	if(!(ppu_screen = malloc(ppu.width * ppu.height * sizeof(Uint32))))
219
+	if(!(ppu_screen = calloc(1, ppu.width * ppu.height * sizeof(Uint32))))
221 220
 		return 0;
222
-	for(i = ppu.width + ppu.height + PAD * 4 - 1; i >= 0; --i)
223
-		ppu_screen[i] = 0;
224 221
 	SDL_UpdateTexture(gTexture, NULL, ppu_screen, sizeof(Uint32));
225 222
 	SDL_StartTextInput();
226 223
 	SDL_ShowCursor(SDL_DISABLE);