1 /* t-support.c - helper functions for the regression tests.
2 * Copyright (C) 2007 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute and/or modify this
7 * part of GnuPG under the terms of either
9 * - the GNU Lesser General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at
11 * your option) any later version.
15 * - the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * or both in parallel, as here.
21 * GnuPG is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.
26 * You should have received a copies of the GNU General Public License
27 * and the GNU Lesser General Public License along with this program;
28 * if not, see <https://www.gnu.org/licenses/>.
38 #include "t-support.h"
41 /* Replacements for the malloc functions as used here. */
46 fprintf (stderr,"error: out of core in regression tests: %s\n",
53 gcry_malloc (size_t n)
59 gcry_xmalloc (size_t n)
68 gcry_strdup (const char *string)
70 char *p = malloc (strlen (string)+1);
78 gcry_realloc (void *a, size_t n)
80 return realloc (a, n);
84 gcry_xrealloc (void *a, size_t n)
86 void *p = realloc (a, n);
95 gcry_calloc (size_t n, size_t m)
101 gcry_xcalloc (size_t n, size_t m)
103 void *p = calloc (n, m);
111 gcry_xstrdup (const char *string)
113 void *p = malloc (strlen (string)+1);
129 /* Stubs for gpg-error functions required because some compilers do
130 not eliminate the supposed-to-be-unused-inline-functions and thus
131 require functions called from these inline functions. */
132 #ifndef GPG_ERROR_H /* Don't do this if gpg-error.h has been included. */
134 gpg_err_code_from_errno (int err)
137 assert (!"stub function");
140 #endif /*GPG_ERROR_H*/
143 /* Retrieve the error code directly from the ERRNO variable. This
144 returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
145 (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
146 #ifndef GPG_ERROR_H /* Don't do this if gpg-error.h has been included. */
148 gpg_err_code_from_syserror (void)
150 assert (!"stub function");
153 #endif /*GPG_ERROR_H*/