mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Plug a memory leak.
Allocating (and not freeing) rects every frame... ouch.
This commit is contained in:
parent
96b80433d8
commit
80f5cc59e9
1 changed files with 10 additions and 4 deletions
|
@ -141,7 +141,8 @@ VID_Init (byte *palette, byte *colormap)
|
|||
void
|
||||
VID_Update (vrect_t *rects)
|
||||
{
|
||||
SDL_Rect *sdlrects;
|
||||
static SDL_Rect *sdlrects;
|
||||
static int num_sdlrects;
|
||||
int i, n;
|
||||
vrect_t *rect;
|
||||
|
||||
|
@ -152,9 +153,14 @@ VID_Update (vrect_t *rects)
|
|||
for (rect = rects; rect; rect = rect->next)
|
||||
++n;
|
||||
|
||||
if (n > num_sdlrects) {
|
||||
num_sdlrects = n;
|
||||
sdlrects = realloc (sdlrects, n * sizeof (SDL_Rect));
|
||||
if (!sdlrects)
|
||||
Sys_Error ("Out of memory!");
|
||||
}
|
||||
|
||||
// Second, copy them to SDL rectangles and update
|
||||
if (!(sdlrects = (SDL_Rect *) calloc (1, n * sizeof (SDL_Rect))))
|
||||
Sys_Error ("Out of memory!");
|
||||
i = 0;
|
||||
for (rect = rects; rect; rect = rect->next) {
|
||||
sdlrects[i].x = rect->x;
|
||||
|
@ -167,7 +173,7 @@ VID_Update (vrect_t *rects)
|
|||
}
|
||||
|
||||
void
|
||||
D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height)
|
||||
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||
{
|
||||
Uint8 *offset;
|
||||
|
||||
|
|
Loading…
Reference in a new issue