1 /* ch_malloc.c - malloc routines that test returns from malloc and friends */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
14 #include <ac/stdlib.h>
16 #include <ac/string.h>
17 #include <ac/socket.h>
30 if ( (new = (void *) ber_memalloc( size )) == NULL ) {
32 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
33 "ch_malloc: allocation of %lu bytes failed\n",
36 Debug( LDAP_DEBUG_ANY, "ch_malloc of %lu bytes failed\n",
54 if ( block == NULL ) {
55 return( ch_malloc( size ) );
62 if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
64 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
65 "ch_realloc: reallocation of %lu bytes failed\n", (long)size ));
67 Debug( LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n",
85 if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
87 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
88 "ch_calloc: allocation of %lu elements of %lu bytes faild\n",
89 (long)nelem, (long)size ));
91 Debug( LDAP_DEBUG_ANY, "ch_calloc of %lu elems of %lu bytes failed\n",
92 (long) nelem, (long) size, 0 );
108 if ( (new = ber_strdup( string )) == NULL ) {
110 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
111 "chr_strdup: duplication of \"%s\" failed\n", string ));
113 Debug( LDAP_DEBUG_ANY, "ch_strdup(%s) failed\n", string, 0, 0 );
116 exit( EXIT_FAILURE );