1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-03 12:24:17 +01:00

Do not allocate memory for a temporary buffer

This kind of things participates in memory fragmentation, so it is
generally a bad practice when an on-stack allocation is enough.
Took opportunity to reduce the buffer size, there's no point in
overallocating memory (the new size being still way too much).

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2019-02-22 17:03:49 +01:00
committed by Carlos R. Mafra
parent dae63b5e96
commit 2913ac0f09
2 changed files with 5 additions and 8 deletions

View File

@@ -1436,12 +1436,12 @@ static WEditMenu *buildSubmenu(_Panel * panel, WMPropList * pl)
WSetEditMenuItemImage(item, panel->markerPix[data->type]);
WSetEditMenuItemData(item, data, (WMCallback *) freeItemData);
} else {
char *buf = wmalloc(1024);
snprintf(buf, 1024, _("Invalid menu command \"%s\" with label \"%s\" cleared"),
char buf[256];
snprintf(buf, sizeof(buf), _("Invalid menu command \"%s\" with label \"%s\" cleared"),
WMGetFromPLString(WMGetFromPLArray(pi, 1)),
WMGetFromPLString(WMGetFromPLArray(pi, 0)));
WMRunAlertPanel(scr, panel->parent, _("Warning"), buf, _("OK"), NULL, NULL);
wfree(buf);
}
}

View File

@@ -380,11 +380,10 @@ void wAppIconMove(WAppIcon * aicon, int x, int y)
static void updateDockNumbers(WScreen *scr)
{
int length;
char *ws_numbers;
char ws_numbers[20];
WAppIcon *dicon = scr->dock->icon_array[0];
ws_numbers = wmalloc(20);
snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace + 1, ((scr->current_workspace / 10) + 1));
snprintf(ws_numbers, sizeof(ws_numbers), "%i [ %i ]", scr->current_workspace + 1, ((scr->current_workspace / 10) + 1));
length = strlen(ws_numbers);
XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, WMFontHeight(scr->icon_title_font) + 1, False);
@@ -394,8 +393,6 @@ static void updateDockNumbers(WScreen *scr)
WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->white,
scr->icon_title_font, 3, 2, ws_numbers, length);
wfree(ws_numbers);
}
#endif /* WS_INDICATOR */