aboutsummaryrefslogtreecommitdiffstats
path: root/tests/t-common.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/t-common.h')
-rw-r--r--tests/t-common.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/t-common.h b/tests/t-common.h
index e70e04d..db496e2 100644
--- a/tests/t-common.h
+++ b/tests/t-common.h
@@ -39,6 +39,33 @@ static void fail (const char *format, ...) GPGRT_ATTR_PRINTF(1,2);
static void show (const char *format, ...) GPGRT_ATTR_PRINTF(1,2);
+static void *
+xmalloc (size_t n)
+{
+ char *p = gpgrt_malloc (n);
+ if (!p)
+ die ("out of core\n");
+ return p;
+}
+
+static char *
+xstrdup (const char *s)
+{
+ char *p = gpgrt_strdup (s);
+ if (!p)
+ die ("out of core\n");
+ return p;
+}
+
+static void
+xfree (void *p)
+{
+ if (p)
+ gpgrt_free (p);
+}
+
+
+
static void
die (const char *format, ...)
{
@@ -57,6 +84,8 @@ die (const char *format, ...)
#ifdef HAVE_FLOCKFILE
funlockfile (stderr);
#endif
+ xfree (xstrdup ("")); /* To avoid compiler warnings. */
+ xfree (xmalloc (16)); /* To avoid compiler warnings. */
exit (1);
}