Moved silc_client_ch[u]mode[_char] to client library from silc/.
[silc.git] / lib / silcutil / 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/09/13 17:45:16  priikone
24  *      Splitted SILC core library. Core library includes now only
25  *      SILC protocol specific stuff. New utility library includes the
26  *      old stuff from core library that is more generic purpose stuff.
27  *
28  * Revision 1.2  2000/07/05 06:05:56  priikone
29  *      Assert if system is out of memory.
30  *
31  * Revision 1.1.1.1  2000/06/27 11:36:55  priikone
32  *      Imported from internal CVS/Added Log headers.
33  *
34  *
35  */
36
37 #include "silcincludes.h"
38
39 void *silc_malloc(size_t size)
40 {
41   void *addr;
42 #ifdef HAVE_MLOCK
43   addr = malloc(size);
44   assert(addr != NULL);
45   mlock(addr, size);
46   return addr;
47 #else
48   addr = malloc(size);
49   assert(addr != NULL);
50   return addr;
51 #endif
52 }
53
54 void *silc_calloc(size_t items, size_t size)
55 {
56   void *addr;
57 #ifdef HAVE_MLOCK
58   addr = calloc(items, size);
59   assert(addr != NULL);
60   mlock(addr, size);
61   return addr;
62 #else
63   addr = calloc(items, size);
64   assert(addr != NULL);
65   return addr;
66 #endif
67 }
68
69 void *silc_realloc(void *ptr, size_t size)
70 {
71   void *addr;
72 #ifdef HAVE_MLOCK
73   addr = realloc(ptr, size);
74   assert(addr != NULL);
75   mlock(addr, size);
76   return addr;
77 #else
78   addr = realloc(ptr, size);
79   assert(addr != NULL);
80   return addr;
81 #endif
82 }
83
84 void silc_free(void *ptr)
85 {
86   free(ptr);
87 }
88
89
90
91
92
93
94