forked from vitrine/wmaker
Chasing memory bugs: be consistent about wmalloc/wfree.
This commit is contained in:
@@ -139,7 +139,7 @@ static WMenu *parseMenuCommand(WScreen * scr, Window win, char **slist, int coun
|
||||
}
|
||||
wstrlcpy(title, &slist[*index][pos], sizeof(title));
|
||||
}
|
||||
data = malloc(sizeof(WAppMenuData));
|
||||
data = wmalloc(sizeof(WAppMenuData));
|
||||
if (data == NULL) {
|
||||
wwarning(_("appmenu: out of memory creating menu for window %lx"), win);
|
||||
wMenuDestroy(menu, True);
|
||||
@@ -152,7 +152,7 @@ static WMenu *parseMenuCommand(WScreen * scr, Window win, char **slist, int coun
|
||||
if (!entry) {
|
||||
wMenuDestroy(menu, True);
|
||||
wwarning(_("appmenu: out of memory creating menu for window %lx"), win);
|
||||
free(data);
|
||||
wfree(data);
|
||||
return NULL;
|
||||
}
|
||||
if (rtext[0] != 0)
|
||||
|
||||
12
src/misc.c
12
src/misc.c
@@ -520,7 +520,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
|
||||
len = strlen(cmdline);
|
||||
olen = len + 1;
|
||||
out = malloc(olen);
|
||||
out = wmalloc(olen);
|
||||
if (!out) {
|
||||
wwarning(_("out of memory during expansion of \"%s\""), cmdline);
|
||||
return NULL;
|
||||
@@ -573,7 +573,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
(unsigned int)scr->focused_window->client_win);
|
||||
slen = strlen(tmpbuf);
|
||||
olen += slen;
|
||||
nout = realloc(out, olen);
|
||||
nout = wrealloc(out, olen);
|
||||
if (!nout) {
|
||||
wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%w", cmdline);
|
||||
goto error;
|
||||
@@ -590,7 +590,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
snprintf(tmpbuf, sizeof(tmpbuf), "0x%x", (unsigned int)scr->current_workspace + 1);
|
||||
slen = strlen(tmpbuf);
|
||||
olen += slen;
|
||||
nout = realloc(out, olen);
|
||||
nout = wrealloc(out, olen);
|
||||
if (!nout) {
|
||||
wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%W", cmdline);
|
||||
goto error;
|
||||
@@ -607,7 +607,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
if (user_input) {
|
||||
slen = strlen(user_input);
|
||||
olen += slen;
|
||||
nout = realloc(out, olen);
|
||||
nout = wrealloc(out, olen);
|
||||
if (!nout) {
|
||||
wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%a", cmdline);
|
||||
goto error;
|
||||
@@ -630,7 +630,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
}
|
||||
slen = strlen(scr->xdestring);
|
||||
olen += slen;
|
||||
nout = realloc(out, olen);
|
||||
nout = wrealloc(out, olen);
|
||||
if (!nout) {
|
||||
wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%d", cmdline);
|
||||
goto error;
|
||||
@@ -651,7 +651,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
||||
}
|
||||
slen = strlen(selection);
|
||||
olen += slen;
|
||||
nout = realloc(out, olen);
|
||||
nout = wrealloc(out, olen);
|
||||
if (!nout) {
|
||||
wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%s", cmdline);
|
||||
goto error;
|
||||
|
||||
@@ -133,7 +133,7 @@ int PropGetGNUstepWMAttr(Window window, GNUstepWMAttributes ** attr)
|
||||
if (!data)
|
||||
return False;
|
||||
|
||||
*attr = malloc(sizeof(GNUstepWMAttributes));
|
||||
*attr = wmalloc(sizeof(GNUstepWMAttributes));
|
||||
if (!*attr) {
|
||||
XFree(data);
|
||||
return False;
|
||||
@@ -183,7 +183,7 @@ void PropSetIconTileHint(WScreen * scr, RImage * image)
|
||||
imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False);
|
||||
}
|
||||
|
||||
tmp = malloc(image->width * image->height * 4 + 4);
|
||||
tmp = wmalloc(image->width * image->height * 4 + 4);
|
||||
if (!tmp) {
|
||||
wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint");
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,7 @@ int main(int argc, char **argv)
|
||||
else
|
||||
ProgName++;
|
||||
|
||||
color_name = (char **)malloc(sizeof(char *) * argc);
|
||||
color_name = (char **)wmalloc(sizeof(char *) * argc);
|
||||
if (color_name == NULL) {
|
||||
fprintf(stderr, "Cannot allocate memory!\n");
|
||||
exit(1);
|
||||
@@ -106,13 +106,13 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
colors = malloc(sizeof(RColor *) * (ncolors + 1));
|
||||
colors = wmalloc(sizeof(RColor *) * (ncolors + 1));
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
if (!XParseColor(dpy, ctx->cmap, color_name[i], &color)) {
|
||||
printf("could not parse color \"%s\"\n", color_name[i]);
|
||||
exit(1);
|
||||
} else {
|
||||
colors[i] = malloc(sizeof(RColor));
|
||||
colors[i] = wmalloc(sizeof(RColor));
|
||||
colors[i]->red = color.red >> 8;
|
||||
colors[i]->green = color.green >> 8;
|
||||
colors[i]->blue = color.blue >> 8;
|
||||
|
||||
Reference in New Issue
Block a user