From 51bc5695d80c040caef90ca25aa65cd5fa438f3a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Sep 2025 17:47:26 +0200 Subject: [PATCH] allocate imgbuf for "to patch" conversions only if needed should save around 64 megs on dedis --- src/r_patch.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index d8e0b94f3..e774c1c2e 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -322,9 +322,6 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps) } } - -static unsigned char imgbuf[1<<26]; - // // Creates a patch. // Assumes a PU_PATCH zone memory tag and no user, but can always be set later @@ -451,6 +448,8 @@ void *Patch_CreateGL(patch_t *patch) } #endif // HWRENDER +static UINT8 *imgbuf = NULL; + // // R_MaskedFlatToPatch // @@ -460,13 +459,17 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I { INT16 x, y; UINT8 *img; - UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; size_t size = 0; if (!raw) return NULL; + if (!imgbuf) + imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL); + + UINT8 *imgptr = imgbuf; + // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height); @@ -580,13 +583,17 @@ void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffs { INT16 x, y; UINT8 *img; - UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; size_t size = 0; if (!raw) return NULL; + if (!imgbuf) + imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL); + + UINT8 *imgptr = imgbuf; + // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height);