tt/mini_isam: use proper include, get rid of ultrix strdup
[oweals/cde.git] / cde / lib / tt / mini_isam / isalloc.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: isalloc.c /main/3 1995/10/23 11:33:43 rswiston $                                                     */
28 #ifndef lint
29 static char sccsid[] = "@(#)isalloc.c 1.3 89/07/17 Copyr 1988 Sun Micro";
30 #endif
31 /*
32  * Copyright (c) 1988 by Sun Microsystems, Inc.
33  */
34
35 /*
36  * isalloc.c
37  *
38  * Description:
39  *      Functions that allocate and deallocate memory.
40  *      All errors are treated as fatal.
41  */
42
43 #include "isam_impl.h"
44 #include <stdlib.h>
45 #include <string.h>
46
47 /*
48  * _ismalloc(nbytes)
49  *
50  * Allocate nbytes.
51  */
52
53 char *_ismalloc(unsigned int nbytes)
54 {
55     char        *p;
56     
57     if ((p = (char *) malloc (nbytes)) == NULL)
58         _isfatal_error("malloc() failed");
59
60     return (p);
61 }
62
63 char *_isrealloc(char *oldaddr, unsigned int nbytes)
64 {
65     char        *p;
66     
67     if ((p = (char *) realloc (oldaddr, nbytes)) == NULL)
68         _isfatal_error("realloc() failed");
69
70     return (p);
71 }
72
73
74 /*
75  * _isallocstring(str)
76  *
77  * Create a duplicate of string in dynamic memory.
78  */
79
80 char *
81 _isallocstring(char *str)
82 {
83     char        *p;
84
85     if ((p = strdup(str)) == NULL) 
86         _isfatal_error("strdup() failed");
87
88     return (p);
89 }
90
91 /*
92  * _isfreestring(str)
93  *
94  * Free dynamically allocated string.
95  */
96
97 void
98 _isfreestring(char *str)
99 {
100     assert(str != NULL);
101     free(str);
102 }