aboutsummaryrefslogtreecommitdiff
path: root/ell.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-20 21:03:04 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-21 13:19:47 +0200
commitf0337aa4819df5ef097837dc02e9a4746da79467 (patch)
treef05abd811f0ddfac6f3c8bebd4ffeeed843735b5 /ell.c
parentfedde03f1e6b47784bd2b7d55247e5f2e08a6385 (diff)
downloadell-f0337aa4819df5ef097837dc02e9a4746da79467.tar.gz
ell-f0337aa4819df5ef097837dc02e9a4746da79467.tar.xz
ell-f0337aa4819df5ef097837dc02e9a4746da79467.zip
Do away with POSIX
Diffstat (limited to 'ell.c')
-rwxr-xr-xell.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/ell.c b/ell.c
index c73ba9e..68a5427 100755
--- a/ell.c
+++ b/ell.c
@@ -17,8 +17,6 @@
*
*/
-#define _XOPEN_SOURCE 500
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -28,7 +26,6 @@
#include <assert.h>
#include <time.h>
#include <stdbool.h>
-#include <strings.h>
#include <math.h>
#include <setjmp.h>
@@ -53,12 +50,12 @@ vformat (const char *format, va_list ap) {
if (size < 0)
return NULL;
- char buf[size + 1];
- size = vsnprintf (buf, sizeof buf, format, ap);
- if (size < 0)
+ char *buf = malloc (size + 1);
+ if (buf && vsnprintf (buf, size + 1, format, ap) < 0) {
+ free (buf);
return NULL;
-
- return strdup (buf);
+ }
+ return buf;
}
static char *
@@ -184,10 +181,7 @@ new_clone_list (const struct item *item) {
}
static struct item *
-new_string (const char *s, ssize_t len) {
- if (len < 0)
- len = strlen (s);
-
+new_string (const char *s, size_t len) {
struct item *item = calloc (1, sizeof *item + len + 1);
if (!item)
return NULL;