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:
committed by
Carlos R. Mafra
parent
8d7db5d744
commit
bd4abc5304
@@ -993,26 +993,20 @@ static void textEditedObserver(void *observerData, WMNotification *notification)
|
|||||||
static void selectSpecification(WMWidget *bPtr, void *data)
|
static void selectSpecification(WMWidget *bPtr, void *data)
|
||||||
{
|
{
|
||||||
InspectorPanel *panel = (InspectorPanel *) data;
|
InspectorPanel *panel = (InspectorPanel *) data;
|
||||||
char *str;
|
char str[256];
|
||||||
WWindow *wwin = panel->inspected;
|
WWindow *wwin = panel->inspected;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class))
|
if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class))
|
||||||
WMSetButtonEnabled(panel->applyBtn, False);
|
WMSetButtonEnabled(panel->applyBtn, False);
|
||||||
else
|
else
|
||||||
WMSetButtonEnabled(panel->applyBtn, True);
|
WMSetButtonEnabled(panel->applyBtn, True);
|
||||||
|
|
||||||
len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
|
snprintf(str, sizeof(str),
|
||||||
+ strlen(wwin->wm_class ? wwin->wm_class : "?");
|
_("Inspecting %s.%s"),
|
||||||
|
wwin->wm_instance ? wwin->wm_instance : "?",
|
||||||
str = wmalloc(len);
|
wwin->wm_class ? wwin->wm_class : "?");
|
||||||
|
|
||||||
snprintf(str, len, _("Inspecting %s.%s"),
|
|
||||||
wwin->wm_instance ? wwin->wm_instance : "?", wwin->wm_class ? wwin->wm_class : "?");
|
|
||||||
|
|
||||||
wFrameWindowChangeTitle(panel->frame->frame, str);
|
wFrameWindowChangeTitle(panel->frame->frame, str);
|
||||||
|
|
||||||
wfree(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void selectWindow(WMWidget *bPtr, void *data)
|
static void selectWindow(WMWidget *bPtr, void *data)
|
||||||
|
|||||||
Reference in New Issue
Block a user