1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

wmaker: Do not allocate memory for a short lived string in 'selectSpecification'

It is not only not very efficient, but in present case it also participates
in memory fragmentation.

This patch replaces this with a stack allocated buffer with a buffer which
is way too large.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2013-11-10 17:41:09 +01:00
committed by Carlos R. Mafra
parent 8d7db5d744
commit bd4abc5304

View File

@@ -993,26 +993,20 @@ static void textEditedObserver(void *observerData, WMNotification *notification)
static void selectSpecification(WMWidget *bPtr, void *data)
{
InspectorPanel *panel = (InspectorPanel *) data;
char *str;
char str[256];
WWindow *wwin = panel->inspected;
int len;
if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class))
WMSetButtonEnabled(panel->applyBtn, False);
else
WMSetButtonEnabled(panel->applyBtn, True);
len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
+ strlen(wwin->wm_class ? wwin->wm_class : "?");
str = wmalloc(len);
snprintf(str, len, _("Inspecting %s.%s"),
wwin->wm_instance ? wwin->wm_instance : "?", wwin->wm_class ? wwin->wm_class : "?");
snprintf(str, sizeof(str),
_("Inspecting %s.%s"),
wwin->wm_instance ? wwin->wm_instance : "?",
wwin->wm_class ? wwin->wm_class : "?");
wFrameWindowChangeTitle(panel->frame->frame, str);
wfree(str);
}
static void selectWindow(WMWidget *bPtr, void *data)