*** empty log message ***
[gnutls.git] / lib / gnutls_mem.c
blobbcb1c26675531e7dcb8b94312e2a007473277280
1 /*
2 * Copyright (C) 2001,2002 Nikos Mavroyanopoulos
4 * This file is part of GNUTLS.
6 * The GNUTLS library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 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 library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <gnutls_int.h>
23 #include <gnutls_errors.h>
24 #include <gnutls_num.h>
26 void* (*gnutls_secure_malloc)(size_t) = malloc;
27 void* (*gnutls_malloc)(size_t) = malloc;
28 void (*gnutls_free)(void*) = free;
30 int _gnutls_is_secure_mem_null( const void* ign) { return 0; }
32 int (*_gnutls_is_secure_memory)(const void*) = _gnutls_is_secure_mem_null;
33 void* (*gnutls_realloc)(void*, size_t) = realloc;
36 void *gnutls_calloc(size_t nmemb, size_t size)
38 void *ret;
39 ret = gnutls_malloc(size);
40 if (ret == NULL)
41 return ret;
43 memset(ret, 0, size);
45 return ret;
48 svoid *gnutls_secure_calloc(size_t nmemb, size_t size)
50 svoid *ret;
51 ret = gnutls_secure_malloc(size);
52 if (ret == NULL)
53 return ret;
55 memset(ret, 0, size);
57 return ret;
60 char *gnutls_strdup(const char *s)
62 int size = strlen(s);
63 char *ret;
65 ret = gnutls_malloc(size + 1); /* hold null */
66 if (ret == NULL)
67 return ret;
69 strcpy(ret, s); /* Flawfinder: ignore */
71 return ret;