2 * Copyright (c) 1996 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
14 * ch_malloc.c - malloc() and friends, with check for NULL return.
21 #include <ac/stdlib.h>
22 #include <ac/socket.h>
24 #include "../slapd/slap.h"
29 * Just like malloc, except we check the returned value and exit
30 * if anything goes wrong.
39 if ( (new = (void *) ber_memalloc( size )) == NULL ) {
40 fprintf( stderr, "malloc of %lu bytes failed\n",
52 * Just like realloc, except we check the returned value and exit
53 * if anything goes wrong.
63 if ( block == NULL ) {
64 return( ch_malloc( size ) );
71 if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
72 fprintf( stderr, "realloc of %lu bytes failed\n",
84 * Just like calloc, except we check the returned value and exit
85 * if anything goes wrong.
95 if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
96 fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
97 (long) nelem, (long) size );
106 * Just like free, except we check to see if p is null.