summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2009-07-14 23:02:14 -0700
committerTrond Norbye <Trond.Norbye@sun.com>2009-08-19 21:28:34 +0200
commit891082f349304fb802c3df7491e337b47771eab1 (patch)
treed67385101a9157a5aaa355b86b1111d60e350bfd /util.c
parent7db0d07c754d1a54116aa2b424b35b429073b15e (diff)
downloadmemcached-891082f349304fb802c3df7491e337b47771eab1.tar.gz
vperror implementation
This allows us to provide much more useful error messages for syscalls.
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/util.c b/util.c
index 307f7f0..083bff4 100644
--- a/util.c
+++ b/util.c
@@ -1,9 +1,10 @@
-#include <stdlib.h>
+#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <stdarg.h>
#include "memcached.h"
@@ -88,3 +89,17 @@ bool safe_strtol(const char *str, int32_t *out) {
}
return false;
}
+
+void vperror(const char *fmt, ...) {
+ int old_errno = errno;
+ char buf[80];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ errno = old_errno;
+
+ perror(buf);
+}