[hackers] [dmenu] drw: a valid (non-NULL) Drw and Fnt context must be passed || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Tue, 20 Oct 2015 23:04:13 +0200 (CEST)

commit 1f2226df1380f178240bb81dddcad6c5ff2e9d62
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Tue Oct 20 22:53:55 2015 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Tue Oct 20 22:53:55 2015 +0200

    drw: a valid (non-NULL) Drw and Fnt context must be passed
    
    don't do these checks on this level. However for resource drw_*_free
    we will allow it.

diff --git a/drw.c b/drw.c
index a98083e..4815e3a 100644
--- a/drw.c
+++ b/drw.c
_AT_@ -82,8 +82,6 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
 void
 drw_resize(Drw *drw, unsigned int w, unsigned int h)
 {
- if (!drw)
- return;
         drw->w = w;
         drw->h = h;
         if (drw->drawable)
_AT_@ -188,8 +186,6 @@ Clr *
 drw_clr_create(Drw *drw, const char *clrname)
 {
         Clr *clr;
- if (!drw)
- return NULL;
 
         clr = ecalloc(1, sizeof(Clr));
         if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
_AT_@ -210,15 +206,13 @@ drw_clr_free(Clr *clr)
 void
 drw_setscheme(Drw *drw, ClrScheme *scheme)
 {
- if (!drw)
- return;
         drw->scheme = scheme;
 }
 
 void
 drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert)
 {
- if (!drw || !drw->scheme)
+ if (!drw->scheme)
                 return;
         XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->pix : drw->scheme->fg->pix);
         if (filled)
_AT_@ -369,8 +363,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
 void
 drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
 {
- if (!drw)
- return;
         XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
         XSync(drw->dpy, False);
 }
_AT_@ -380,8 +372,6 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *tex)
 {
         XGlyphInfo ext;
 
- if (!font || !text)
- return;
         XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
         tex->h = font->h;
         tex->w = ext.xOff;
_AT_@ -392,9 +382,8 @@ drw_font_getexts_width(Fnt *font, const char *text, unsigned int len)
 {
         Extnts tex;
 
- if (!font)
- return -1;
         drw_font_getexts(font, text, len, &tex);
+
         return tex.w;
 }
 
_AT_@ -403,8 +392,6 @@ drw_cur_create(Drw *drw, int shape)
 {
         Cur *cur;
 
- if (!drw)
- return NULL;
         cur = ecalloc(1, sizeof(Cur));
         cur->cursor = XCreateFontCursor(drw->dpy, shape);
 
_AT_@ -414,7 +401,7 @@ drw_cur_create(Drw *drw, int shape)
 void
 drw_cur_free(Drw *drw, Cur *cursor)
 {
- if (!drw || !cursor)
+ if (!cursor)
                 return;
         XFreeCursor(drw->dpy, cursor->cursor);
         free(cursor);
Received on Tue Oct 20 2015 - 23:04:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Oct 20 2015 - 23:12:15 CEST