From 1c041c72ecacc838985b2406568acf2b98939041 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Mon, 30 Jan 2012 17:15:37 +0200 Subject: [PATCH] Free unused strings from memory --- data/qcsrc/client/hud.qc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index ea52cda3..c0983860 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -1708,10 +1708,26 @@ void Sbar_Portrait() return; if(portrait_time + cvar("sbar_portrait_time") >= time) - if(portrait_image && portrait_name) // prevent using bad strings { - drawpic(left - '120 80 0' - fade_pos, portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - drawcolorcodedstring(left - '120 -80 0' - fade_pos, textShortenToWidth(portrait_name, 120, '12 12 0', stringwidth_colors), '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + if(portrait_image && portrait_name) // prevent using bad strings + { + drawpic(left - '120 80 0' - fade_pos, portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + drawcolorcodedstring(left - '120 -80 0' - fade_pos, textShortenToWidth(portrait_name, 120, '12 12 0', stringwidth_colors), '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + } + else + { + // free unused strings from memory + if(portrait_image) + { + strunzone(portrait_image); + portrait_image = string_null; + } + if(portrait_name) + { + strunzone(portrait_name); + portrait_name = string_null; + } } } -- 2.39.2