From: Christophe CURIS <[email protected]>

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 <[email protected]>
---
 src/winspector.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 8cb49df..1e185f5 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -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)
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to