From 876386066faef580f32e578c40a9c2b6f90bb50f Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 14 Aug 2023 19:34:10 -0400 Subject: [PATCH] Release dragon_scales_color obuf in doname_base Apply logic from vanilla commit e43ec0cef1cc7c4e639c7de7e1d9ff26c6c8c629 to an xnh-specific function -- prevent it from needlessly consuming extra obufs when churning through a lot of inventory (assuming there are a bunch of dragon-scaled items in there). --- src/objnam.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/objnam.c b/src/objnam.c index a1db242d3..d4406ee90 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1296,9 +1296,10 @@ doname_base( arti_light_description(obj)); } if (Is_dragon_scaled_armor(obj)) { - char scalebuf[30]; - Sprintf(scalebuf, "%s-scaled ", dragon_scales_color(obj)); + char scalebuf[30], *colorstr = dragon_scales_color(obj); + Sprintf(scalebuf, "%s-scaled ", colorstr); Strcat(prefix, scalebuf); + releaseobuf(colorstr); /* don't consume an extra obuf */ } /*FALLTHRU*/ case WEAPON_CLASS: @@ -5544,7 +5545,7 @@ shirt_simple_name(struct obj *shirt UNUSED) char * dragon_scales_color(struct obj *obj) { - char* buf = nextobuf(); + char *buf = nextobuf(); if (!obj) { impossible("dragon_scales_color: null obj"); return NULL;