From 6549dede60bc1b2dde4e29aad19cf7ec71076c96 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 30 Aug 2018 15:47:44 +0200 Subject: Sanitize C++11 --- src/x11util.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/x11util.cpp') diff --git a/src/x11util.cpp b/src/x11util.cpp index f56d31e..775f072 100644 --- a/src/x11util.cpp +++ b/src/x11util.cpp @@ -16,15 +16,16 @@ static int eHandler(Display* dpy, XErrorEvent* e) } extern "C" -void AddPixmapToBackground(unsigned const char* imgData, int width, int height, int depth, int bytesPerLine, int byteCount) +void AddPixmapToBackground(unsigned const char* imgData, const unsigned int width, const unsigned int height, + const unsigned int depth, const int bytesPerLine, const size_t byteCount) { Pixmap pix = 0; - GC gc = NULL; - XImage *xi = NULL; + GC gc = nullptr; + XImage *xi = nullptr; XGCValues gc_init; memset(&gc_init, 0, sizeof(gc_init)); - Display* dpy = XOpenDisplay(NULL); - if (dpy == NULL) + Display* dpy = XOpenDisplay(nullptr); + if (dpy == nullptr) return; XSetErrorHandler(&eHandler); int screen = DefaultScreen(dpy); @@ -32,7 +33,7 @@ void AddPixmapToBackground(unsigned const char* imgData, int width, int height, char *data = (char*)malloc(byteCount); memcpy(data, imgData, byteCount); xi = XCreateImage(dpy, CopyFromParent, depth, ZPixmap, 0, data, width, height, 32, bytesPerLine); - if (xi == NULL) + if (xi == nullptr) goto cleanup; pix = XCreatePixmap(dpy, root, width, height, (unsigned int)DefaultDepth(dpy, screen)); if (pix == 0) @@ -40,23 +41,23 @@ void AddPixmapToBackground(unsigned const char* imgData, int width, int height, gc_init.foreground = BlackPixel(dpy, screen); gc_init.background = WhitePixel(dpy, screen); gc = XCreateGC(dpy, pix, GCForeground|GCBackground, &gc_init); - if (gc == NULL) + if (gc == nullptr) goto cleanup; int res1, res2, res3; res1 = XPutImage(dpy, pix, gc, xi, 0, 0, 0, 0, width, height); res2 = XSetWindowBackgroundPixmap(dpy, root, pix); res3 = XClearWindow(dpy, root); cleanup: - if (gc != NULL) { + if (gc != nullptr) { XFreeGC(dpy, gc); } if (pix != 0) { XFreePixmap(dpy, pix); } - if (xi != NULL) { + if (xi != nullptr) { XDestroyImage(xi); } - if (dpy != NULL) { + if (dpy != nullptr) { XCloseDisplay(dpy); } } -- cgit v1.2.3-55-g7522