]> git.sur5r.net Git - openldap/blob - contrib/tweb/ch_malloc.c
Update man page date.
[openldap] / contrib / tweb / ch_malloc.c
1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 *                                                                          *
3 * ch_malloc.c                                                              *
4 *                                                                          *
5 * Function:..Alloc-Functions with Error-Handling                           *
6 *                                                                          *
7 *            from LDAP3.2 University of Michigan                           *
8 *                                                                          *
9 *            Patch: unsigned long --> size_t fuer size-Parameter           *
10 *                                                                          *
11 *                                                                          *
12 * Authors:...Dr. Kurt Spanier & Bernhard Winkler,                          *
13 *            Zentrum fuer Datenverarbeitung, Bereich Entwicklung           *
14 *            neuer Dienste, Universitaet Tuebingen, GERMANY                *
15 *                                                                          *
16 *                                       ZZZZZ  DDD    V   V                *
17 *            Creation date:                Z   D  D   V   V                *
18 *            April 16 1996                Z    D   D   V V                 *
19 *            Last modification:          Z     D  D    V V                 *
20 *            December 31 1998           ZZZZ   DDD      V                  *
21 *                                                                          *
22 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
23
24 /*
25  * $Id: ch_malloc.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $
26  *
27  */
28
29 #include "tgeneral.h"
30 #include "tglobal.h"
31
32 #include "ch_malloc_exp.h"
33 #include "support_exp.h"
34
35
36 /* ch_malloc.c - malloc routines that test returns from malloc and friends */
37
38 PUBLIC char * ch_malloc( size )
39 size_t size;
40 {
41         char    *new;
42
43         if ( (new = (char *) calloc(1, size )) == NULL ) {
44                 if (dosyslog) syslog( LOG_INFO, "malloc of %d bytes failed\n", size );
45                 exit_tweb( 1 );
46         }
47
48         return( new );
49 }
50 /* end of function: ch_malloc */
51
52 PUBLIC char * ch_realloc( block, size )
53 char            *block;
54 size_t size;
55 {
56         char    *new;
57
58         if ( block == NULL ) {
59                 return( ch_malloc( size ) );
60         }
61
62         if ( (new = (char *) realloc( block, size )) == NULL ) {
63                 if (dosyslog) syslog( LOG_INFO, "realloc of %d bytes failed\n", size );
64                 exit_tweb( 1 );
65         }
66
67         return( new );
68 }
69 /* end of function: ch_realloc */
70
71 PUBLIC char * ch_calloc( nelem, size )
72 size_t nelem;
73 size_t size;
74 {
75         char    *new;
76
77         if ( (new = (char *) calloc( nelem, size )) == NULL ) {
78                 if (dosyslog) syslog( LOG_INFO, "calloc of %d elems of %d bytes failed\n",
79                   nelem, size );
80                 exit_tweb( 1 );
81         }
82
83         return( new );
84 }
85 /* end of function: ch_calloc */