summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drw.c19
-rw-r--r--util.c10
-rw-r--r--util.h1
3 files changed, 18 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;
diff --git a/util.c b/util.c
index 9b27512..6b703e9 100644
--- a/util.c
+++ b/util.c
@@ -6,6 +6,16 @@
#include "util.h"
+void *
+ecalloc(size_t nmemb, size_t size)
+{
+ void *p;
+
+ if (!(p = calloc(nmemb, size)))
+ perror(NULL);
+ return p;
+}
+
void
die(const char *fmt, ...) {
va_list ap;
diff --git a/util.h b/util.h
index f7ce721..cded043 100644
--- a/util.h
+++ b/util.h
@@ -5,3 +5,4 @@
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
void die(const char *errstr, ...);
+void *ecalloc(size_t, size_t);
.com/avatar/cfc8de1759d4fb94d4fe17b6e46f1ece?s=13&d=retro' width='13' height='13' alt='Gravatar' /> Hiltjo Posthuma 1-3/+9 These variables make it simpler to change the paths to this for ports. `pkg-config` is avoided because it sucks, in particular for cross-compilation. A commented path for *BSD is added, the Xft includes are located at: /usr/X11R6/include there. Also already bump the version number to 4.6, a release will come approximately in August. 2015-07-19fix prompt color style how it used to beGravatar Hiltjo Posthuma 1-1/+1 This is the style how it was before the big Xft change. The colors were inverted, this was not the case before the change. Reported by "zvz" on #suckless IRC, thanks! 2015-06-27Use libdraw: add Xft and fallback-fonts support to graphics libGravatar Hiltjo Posthuma 11-316/+684 - libdraw, util: add drw.{c,h}, util.{c,h} and update code. - libdraw: fix drw_rect(): use w and h parameter. - libdraw: print errstr if last character in string was ":" (sbase). - libdraw: drw_clr_free() allow valid free(NULL). - config.def.h: set default font to monospace. - cleanup() on exit. - LICENSE: update license string for dmenu -v to 2015. - LICENSE: add myself to LICENSE 2014-09-17applied Hiltjo's patch as suggested on the ml to fix ControlMask for C-j and C-mGravatar Anselm R Garbe 2-2/+5 2014-07-30fix crash with ctrl-enter as inputGravatar Hiltjo Posthuma 1-1/+2 reproduce: ./dmenu; send EOF; press ctrl+enter. 2014-05-29updated copyright notices in LICENSE and dmenu.c fileGravatar Anselm R Garbe 2-2/+2 2013-08-13applied Martin Kühl's inverse matching flag to stestGravatar Anselm R Garbe 2-4/+7 2013-08-02applied Martti Kühne's dmenu monitor patchGravatar Anselm R Garbe 3-4/+14 https://gist.github.com/mar77i/3349298/raw/f6581ca96627f4c71c0bd1faf531daaf2a613b95/monarg.patch becomes upstream now 2013-06-28accepted vi'is exit approach ^[ (suggested by Arkaduisz)Gravatar Anselm R Garbe 1-0/+2