Skip to content

Commit

Permalink
- get rid of M_Malloc call in WriteSavePic
Browse files Browse the repository at this point in the history
Use TArray instead
  • Loading branch information
coelckers committed Jul 29, 2022
1 parent b9501a7 commit 5bae588
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/rendering/hwrenderer/hw_entrypoint.cpp
Expand Up @@ -284,12 +284,10 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
RenderState.EnableStencil(false);
RenderState.SetNoSoftLightLevel();

int numpixels = width * height;
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
TArray<uint8_t> scr(width * height * 3, true);
screen->CopyScreenToBuffer(width, height, scr);

DoWriteSavePic(file, SS_RGB, scr, width, height, viewsector, screen->FlipSavePic());
M_Free(scr);
DoWriteSavePic(file, SS_RGB, scr.Data(), width, height, viewsector, screen->FlipSavePic());

// Switch back the screen render buffers
screen->SetViewportRects(nullptr);
Expand Down

0 comments on commit 5bae588

Please sign in to comment.