Remove hacks which are not anymore needed since we now require Libgcrypt 1.4
[gnupg.git] / jnlib / t-support.c
blob9b84634f86a47043a19ef2289cc6560d7d36bd1f
1 /* t-support.c - helper functions for the regression tests.
2 * Copyright (C) 2007 Free Software Foundation, Inc.
4 * This file is part of JNLIB.
6 * JNLIB is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * JNLIB is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <config.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
26 #include "t-support.h"
28 /* Replacements for the malloc functions as used here. */
30 static void
31 out_of_memory (void)
33 fprintf (stderr,"error: out of core in regression tests: %s\n",
34 strerror (errno));
35 exit (2);
39 void *
40 gcry_malloc (size_t n)
42 return malloc (n);
45 void *
46 gcry_xmalloc (size_t n)
48 void *p = malloc (n);
49 if (!p)
50 out_of_memory ();
51 return p;
54 char *
55 gcry_strdup (const char *string)
57 return malloc (strlen (string)+1);
61 void *
62 gcry_realloc (void *a, size_t n)
64 return realloc (a, n);
67 void *
68 gcry_xrealloc (void *a, size_t n)
70 void *p = realloc (a, n);
71 if (!p)
72 out_of_memory ();
73 return p;
78 void *
79 gcry_calloc (size_t n, size_t m)
81 return calloc (n, m);
84 void *
85 gcry_xcalloc (size_t n, size_t m)
87 void *p = calloc (n, m);
88 if (!p)
89 out_of_memory ();
90 return p;
94 char *
95 gcry_xstrdup (const char *string)
97 void *p = malloc (strlen (string)+1);
98 if (!p)
99 out_of_memory ();
100 strcpy (p, string);
101 return p;
104 void
105 gcry_free (void *a)
107 if (a)
108 free (a);