3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1996 Regents of the University of Michigan.
10 * Redistribution and use in source and binary forms are permitted
11 * provided that this notice is preserved and that due credit is given
12 * to the University of Michigan at Ann Arbor. The name of the University
13 * may not be used to endorse or promote products derived from this
14 * software without specific prior written permission. This software
15 * is provided ``as is'' without express or implied warranty.
21 * ch_malloc.c - malloc() and friends, with check for NULL return.
28 #include <ac/stdlib.h>
29 #include <ac/socket.h>
31 #include "../slapd/slap.h"
37 * Just like malloc, except we check the returned value and exit
38 * if anything goes wrong.
47 if ( (new = (void *) ber_memalloc( size )) == NULL ) {
48 fprintf( stderr, "malloc of %lu bytes failed\n",
60 * Just like realloc, except we check the returned value and exit
61 * if anything goes wrong.
71 if ( block == NULL ) {
72 return( ch_malloc( size ) );
79 if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
80 fprintf( stderr, "realloc of %lu bytes failed\n",
92 * Just like calloc, except we check the returned value and exit
93 * if anything goes wrong.
103 if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
104 fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
105 (long) nelem, (long) size );
106 exit( EXIT_FAILURE );
114 * Just like free, except we check to see if p is null.