1 /* no-libgcrypt.c - Replacement functions for libgcrypt.
2 * Copyright (C) 2003 Free Software Foundation, Inc.
4 * This file is free software; as a special exception the author gives
5 * unlimited permission to copy and/or distribute it, with or without
6 * modifications, as long as this notice is preserved.
8 * This file is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 #include "../common/util.h"
24 /* Replace libgcrypt's malloc functions which are used by
25 ../jnlib/libjnlib.a . ../common/util.h defines macros to map them
30 log_fatal (_("error allocating enough memory: %s\n"), strerror (errno
));
35 gcry_malloc (size_t n
)
41 gcry_malloc_secure (size_t n
)
47 gcry_xmalloc (size_t n
)
56 gcry_strdup (const char *string
)
58 return malloc (strlen (string
)+1);
63 gcry_realloc (void *a
, size_t n
)
65 return realloc (a
, n
);
69 gcry_xrealloc (void *a
, size_t n
)
71 void *p
= realloc (a
, n
);
80 gcry_calloc (size_t n
, size_t m
)
86 gcry_xcalloc (size_t n
, size_t m
)
88 void *p
= calloc (n
, m
);
96 gcry_xstrdup (const char *string
)
98 void *p
= malloc (strlen (string
)+1);
113 /* We need this dummy because exechelp.c uses gcry_control to
114 terminate the secure memeory. */
116 gcry_control (enum gcry_ctl_cmds cmd
, ...)
123 gcry_set_outofcore_handler (gcry_handler_no_mem_t h
, void *opaque
)
130 gcry_set_fatalerror_handler (gcry_handler_error_t fnc
, void *opaque
)
137 gcry_set_log_handler (gcry_handler_log_t f
, void *opaque
)