]> git.sur5r.net Git - openldap/blob - libraries/liblber/memory.c
First cut at ber_set_option(NULL,LBER_OPT_MEMORY_FN, myrealloc) where
[openldap] / libraries / liblber / memory.c
1 /*
2  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5 #include "portable.h"
6
7 #include <stdlib.h>
8
9 #include "lber-int.h"
10
11 void
12 ber_memfree( void *p )
13 {
14     ber_int_options.lbo_valid = LBER_INITIALIZED;
15         LBER_FREE( p );
16 }
17
18 void *
19 ber_memalloc( size_t s )
20 {
21     ber_int_options.lbo_valid = LBER_INITIALIZED;
22         return LBER_MALLOC( s );
23 }
24
25 void *
26 ber_memcalloc( size_t n, size_t s )
27 {
28     ber_int_options.lbo_valid = LBER_INITIALIZED;
29         return LBER_CALLOC( n, s );
30 }
31
32 void *
33 ber_memrealloc( void* p, size_t s )
34 {
35     ber_int_options.lbo_valid = LBER_INITIALIZED;
36         return LBER_REALLOC( p, s );
37 }
38
39 BER_MEMORY_FN ber_int_realloc = NULL;
40
41 void *
42 ber_int_calloc( size_t n, size_t s )
43 {
44     ber_int_options.lbo_valid = LBER_INITIALIZED;
45
46         {
47                 size_t size = n * s;
48                 void *p = (*ber_int_realloc)( NULL, size );
49                 return p ?  memset( p, 0, size ) : p;
50         }
51 }
52