Cleanup dmenu filter.

This commit is contained in:
Jari Vetoniemi 2014-04-11 23:58:36 +03:00
parent 3c6e167578
commit 5a0a2659ed

View File

@ -98,13 +98,15 @@ bmItem** _bmFilterDmenuFun(bmMenu *menu, char addition, char* (*fstrstr)(const c
items = bmMenuGetItems(menu, &itemsCount); items = bmMenuGetItems(menu, &itemsCount);
} }
char *buffer = NULL;
bmItem **filtered = calloc(itemsCount, sizeof(bmItem*)); bmItem **filtered = calloc(itemsCount, sizeof(bmItem*));
if (!filtered) if (!filtered)
return NULL; goto fail;
char **tokv; char **tokv;
unsigned int tokc; unsigned int tokc;
char *buffer = _bmFilterTokenize(menu, &tokv, &tokc); if (!(buffer = _bmFilterTokenize(menu, &tokv, &tokc)))
goto fail;
bmItem *highlighted = bmMenuGetHighlightedItem(menu); bmItem *highlighted = bmMenuGetHighlightedItem(menu);
@ -129,11 +131,17 @@ bmItem** _bmFilterDmenuFun(bmMenu *menu, char addition, char* (*fstrstr)(const c
if (buffer) if (buffer)
free(buffer); free(buffer);
if (tokv) if (tokv)
free(tokv); free(tokv);
return _bmFilterShrinkList(&filtered, menu->items.count, (*outNmemb = f)); return _bmFilterShrinkList(&filtered, menu->items.count, (*outNmemb = f));
fail:
if (filtered)
free(filtered);
if (buffer)
free(buffer);
return NULL;
} }
/** /**