mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 22:28:02 +01:00
wmaker: replaced temporary allocation by local storage for error message
In case of problem with a directory when building the list of files for the Icon Chooser dialog, an error message was generated using a temporary allocated buffer. This is not really good for memory fragmentation, so this patch re-uses the local buffer which will be enough for all reasonable cases. Took opportunity to make message less prone to translation difficulties, and include more information about the problem to the user so he may know what went wrong. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
7542451a04
commit
7bf2565316
14
src/dialog.c
14
src/dialog.c
@@ -35,6 +35,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
@@ -572,16 +573,11 @@ static void listPixmaps(WScreen *scr, WMList *lPtr, const char *path)
|
||||
dir = opendir(apath);
|
||||
|
||||
if (!dir) {
|
||||
char *msg;
|
||||
char *tmp;
|
||||
tmp = _("Could not open directory ");
|
||||
msg = wmalloc(strlen(tmp) + strlen(path) + 6);
|
||||
strcpy(msg, tmp);
|
||||
strcat(msg, path);
|
||||
|
||||
wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
|
||||
wfree(msg);
|
||||
wfree(apath);
|
||||
snprintf(pbuf, sizeof(pbuf),
|
||||
_("Could not open directory \"%s\":\n%s"),
|
||||
path, strerror(errno));
|
||||
wMessageDialog(scr, _("Error"), pbuf, _("OK"), NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user