Initial revision
[silc.git] / lib / silccore / silcmemory.c
1 /*
2
3   silcmemory.c
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1999 - 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20 /*
21  * $Id$
22  * $Log$
23  * Revision 1.1  2000/06/27 11:36:55  priikone
24  * Initial revision
25  *
26  *
27  */
28
29 #include "silcincludes.h"
30
31 void *silc_malloc(size_t size)
32 {
33 #ifdef HAVE_MLOCK
34   void *addr = malloc(size);
35   mlock(addr, size);
36   return addr;
37 #else
38   return malloc(size);
39 #endif
40 }
41
42 void *silc_calloc(size_t items, size_t size)
43 {
44 #ifdef HAVE_MLOCK
45   void *addr = calloc(items, size);
46   mlock(addr, size);
47   return addr;
48 #else
49   return calloc(items, size);
50 #endif
51 }
52
53 void *silc_realloc(void *ptr, size_t size)
54 {
55 #ifdef HAVE_MLOCK
56   void *addr = realloc(ptr, size);
57   mlock(addr, size);
58   return addr;
59 #else
60   return realloc(ptr, size);
61 #endif
62 }
63
64 void silc_free(void *ptr)
65 {
66   free(ptr);
67 }
68
69
70
71
72
73
74