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 ../common/libcommon.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 char *p = malloc (strlen (string)+1);
66 gcry_realloc (void *a, size_t n)
68 return realloc (a, n);
72 gcry_xrealloc (void *a, size_t n)
74 void *p = realloc (a, n);
83 gcry_calloc (size_t n, size_t m)
89 gcry_xcalloc (size_t n, size_t m)
91 void *p = calloc (n, m);
99 gcry_xstrdup (const char *string)
101 void *p = malloc (strlen (string)+1);
116 /* We need this dummy because exechelp.c uses gcry_control to
117 terminate the secure memeory. */
119 gcry_control (enum gcry_ctl_cmds cmd, ...)
126 gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque)
133 gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque)
140 gcry_set_log_handler (gcry_handler_log_t f, void *opaque)
148 gcry_create_nonce (void *buffer, size_t length)
153 log_fatal ("unexpected call to gcry_create_nonce\n");
158 gcry_cipher_algo_name (int algo)