Add help strings for all commands.
[gnupg.git] / kbx / keybox-util.c
blob84de504c4034fc31e22e29849ba5d22c47b47fa0
1 /* keybox-util.c - Utility functions for Keybox
2 * Copyright (C) 2001 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <config.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
25 #include "keybox-defs.h"
28 static void *(*alloc_func)(size_t n) = malloc;
29 static void *(*realloc_func)(void *p, size_t n) = realloc;
30 static void (*free_func)(void*) = free;
34 void
35 keybox_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
36 void *(*new_realloc_func)(void *p, size_t n),
37 void (*new_free_func)(void*) )
39 alloc_func = new_alloc_func;
40 realloc_func = new_realloc_func;
41 free_func = new_free_func;
44 void *
45 _keybox_malloc (size_t n)
47 return alloc_func (n);
50 void *
51 _keybox_realloc (void *a, size_t n)
53 return realloc_func (a, n);
56 void *
57 _keybox_calloc (size_t n, size_t m)
59 void *p = _keybox_malloc (n*m);
60 if (p)
61 memset (p, 0, n* m);
62 return p;
65 void
66 _keybox_free (void *p)
68 if (p)
69 free_func (p);