Introduction
Introduction Statistics Contact Development Disclaimer Help
put estrdup in util and use die() instead of BSD err() - svkbd - simple virtual…
git clone git://git.suckless.org/svkbd
Log
Files
Refs
README
LICENSE
---
commit d19a80dfe5996a6e8b734a4118a423e71ee908c5
parent b80819aa3f7eea32252d7885b09763d340540e4c
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 28 Mar 2021 14:41:32 +0200
put estrdup in util and use die() instead of BSD err()
Diffstat:
M svkbd.c | 9 ---------
M util.c | 10 ++++++++++
M util.h | 1 +
3 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/svkbd.c b/svkbd.c
@@ -11,7 +11,6 @@
#include <time.h>
#include <unistd.h>
#include <ctype.h>
-#include <err.h>
#include <X11/keysym.h>
#include <X11/keysymdef.h>
@@ -85,8 +84,6 @@ static void togglelayer();
static void unpress(Key *k, KeySym mod);
static void updatekeys();
static void printkey(Key *k, KeySym mod);
-static char *estrdup(const char *str);
-
/* variables */
static int screen;
@@ -138,12 +135,6 @@ Bool sigtermd = False;
static Key keys[KEYS] = { NULL };
static Key* layers[LAYERS];
-char * estrdup(const char *str) {
- char * tmp = strdup(str);
- if (tmp == NULL) errx(1, "strdup failed");
- return tmp;
-}
-
void
motionnotify(XEvent *e)
{
diff --git a/util.c b/util.c
@@ -16,6 +16,16 @@ ecalloc(size_t nmemb, size_t size)
return p;
}
+char *
+estrdup(const char *s)
+{
+ char *p;
+
+ if (!(p = strdup(s)))
+ die("strdup:");
+ return p;
+}
+
void
die(const char *fmt, ...)
{
diff --git a/util.h b/util.h
@@ -6,3 +6,4 @@
void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size);
+char *estrdup(const char *s);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.