aboutsummaryrefslogtreecommitdiffstats
path: root/libsimple.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-29 12:55:52 +0200
committerMattias Andrée <maandree@kth.se>2018-08-29 12:55:52 +0200
commit280258050d3c129614d60bca4d6df31288dc2573 (patch)
treea72ecb0feaf0ca0659383ff2eb3707a9e4340eb6 /libsimple.h
parentAdd tests (diff)
downloadlibsimple-280258050d3c129614d60bca4d6df31288dc2573.tar.gz
libsimple-280258050d3c129614d60bca4d6df31288dc2573.tar.bz2
libsimple-280258050d3c129614d60bca4d6df31288dc2573.tar.xz
Add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libsimple.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/libsimple.h b/libsimple.h
index 24dda8b..6681aad 100644
--- a/libsimple.h
+++ b/libsimple.h
@@ -477,9 +477,9 @@ extern int libsimple_default_failure_exit;
#endif
-#define FREE(PTR) ((void)(free(PTR), (PTR) = NULL)) /* TODO test */
+#define FREE(PTR) ((void)(free(PTR), (PTR) = NULL))
-#define CLOSE(FD) libsimple_close(&(FD)) /* TODO test */
+#define CLOSE(FD) libsimple_close(&(FD))
_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__)))
static inline int
@@ -627,7 +627,7 @@ int libsimple_vasprintf(char **, const char *, va_list);
#endif
#if defined(__GNUC__) && !defined(__clang__)
-# define libsimple_asprintfa(__fmt, ...) /* TODO test */\
+# define libsimple_asprintfa(__fmt, ...)\
({\
const char *__f = (__fmt);\
char *__ret = NULL;\
@@ -644,20 +644,22 @@ int libsimple_vasprintf(char **, const char *, va_list);
#endif
#if defined(__GNUC__) || defined(__clang__)
-# define libsimple_vasprintfa(__fmt, __ap) /* TODO test */\
+# define libsimple_vasprintfa(__fmt, __ap)\
({\
const char *__f = (__fmt);\
- va_list __a = (__ap);\
+ va_list __a1;\
va_list __a2;\
char *__ret = NULL;\
int __r;\
- va_copy(__a2, __a);\
- __r = vsnprintf(NULL, 0, __f, __a);\
+ va_copy(__a1, __ap);\
+ va_copy(__a2, __a1);\
+ __r = vsnprintf(NULL, 0, __f, __a1);\
if (__r >= 0) {\
__ret = alloca((size_t)__r + 1);\
vsprintf(__ret, __f, __a2);\
}\
va_end(__a2);\
+ va_end(__a1);\
__ret;\
})
# ifndef vasprintfa