3 * Copyright (c) 1996 Regents of the University of Michigan.
6 * Redistribution and use in source and binary forms are permitted
7 * provided that this notice is preserved and that due credit is given
8 * to the University of Michigan at Ann Arbor. The name of the University
9 * may not be used to endorse or promote products derived from this
10 * software without specific prior written permission. This software
11 * is provided ``as is'' without express or implied warranty.
17 * ch_malloc.c - malloc() and friends, with check for NULL return.
24 #include <ac/stdlib.h>
25 #include <ac/socket.h>
27 #include "../slapd/slap.h"
33 * Just like malloc, except we check the returned value and exit
34 * if anything goes wrong.
43 if ( (new = (void *) ber_memalloc( size )) == NULL ) {
44 fprintf( stderr, "malloc of %lu bytes failed\n",
56 * Just like realloc, except we check the returned value and exit
57 * if anything goes wrong.
67 if ( block == NULL ) {
68 return( ch_malloc( size ) );
75 if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
76 fprintf( stderr, "realloc of %lu bytes failed\n",
88 * Just like calloc, except we check the returned value and exit
89 * if anything goes wrong.
99 if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
100 fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
101 (long) nelem, (long) size );
102 exit( EXIT_FAILURE );
110 * Just like free, except we check to see if p is null.