aboutsummaryrefslogtreecommitdiff
path: root/drw.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-10-20 22:51:57 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-10-20 22:51:57 +0200
commit5a20b409c673a6736c3f9326cb54edc32908f717 (patch)
tree9b30985369ab49bd7588127411d9cf2209f19efb /drw.c
parent164986763a29db97abb52b15cbd282b5636d83c0 (diff)
downloaddmenu-5a20b409c673a6736c3f9326cb54edc32908f717.tar.gz
dmenu-5a20b409c673a6736c3f9326cb54edc32908f717.tar.bz2
dmenu-5a20b409c673a6736c3f9326cb54edc32908f717.zip
add sbase-style ecalloc(), calloc: or die
... remove intermediary variables
Diffstat (limited to 'drw.c')
-rw-r--r--drw.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drw.c b/drw.c
index 6aeb59d..a98083e 100644
--- a/drw.c
+++ b/drw.c
@@ -65,8 +65,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
{
Drw *drw;
- if (!(drw = calloc(1, sizeof(Drw))))
- return NULL;
+ drw = ecalloc(1, sizeof(Drw));
drw->dpy = dpy;
drw->screen = screen;
drw->root = root;
@@ -189,16 +188,13 @@ Clr *
drw_clr_create(Drw *drw, const char *clrname)
{
Clr *clr;
- Colormap cmap;
- Visual *vis;
-
if (!drw)
return NULL;
- if (!(clr = calloc(1, sizeof(Clr))))
- return NULL;
- cmap = DefaultColormap(drw->dpy, drw->screen);
- vis = DefaultVisual(drw->dpy, drw->screen);
- if (!XftColorAllocName(drw->dpy, vis, cmap, clrname, &clr->rgb))
+
+ clr = ecalloc(1, sizeof(Clr));
+ if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
+ DefaultColormap(drw->dpy, drw->screen),
+ clrname, &clr->rgb))
die("error, cannot allocate color '%s'\n", clrname);
clr->pix = clr->rgb.pixel;
@@ -409,8 +405,7 @@ drw_cur_create(Drw *drw, int shape)
if (!drw)
return NULL;
- if (!(cur = calloc(1, sizeof(Cur))))
- return NULL;
+ cur = ecalloc(1, sizeof(Cur));
cur->cursor = XCreateFontCursor(drw->dpy, shape);
return cur;