Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtSvc / DtEncap / MemoryMgr.c
1 /*
2  * File:         MemoryMgr.c $XConsortium: MemoryMgr.c /main/3 1995/10/26 15:34:54 rswiston $
3  * Language:     C
4  *
5  * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
6  *
7  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
8  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
9  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
10  * (c) Copyright 1993, 1994 Novell, Inc.                                *
11  */
12
13 #ifdef DOMAIN_ALLOW_MALLOC_OVERRIDE
14 #include "/usr/include/apollo/shlib.h"
15 #endif
16
17 #include <bms/sbport.h> /* NOTE: sbport.h must be the first include. */
18
19 #include <bms/bms.h>
20 #include <bms/XeUserMsg.h>
21 #include <bms/MemoryMgr.h>
22
23 #ifdef __cplusplus
24 #define CPLUSPLUS_MALLOC_TYPE (malloc_t)
25 #else
26 #define CPLUSPLUS_MALLOC_TYPE
27 #endif
28
29 /*-----------------------------------------------------------------------+*/
30 void * XeMalloc( size_t size )
31 /*-----------------------------------------------------------------------+*/
32 {
33     XeString  ptr;
34     
35     if (!size) return 0;
36     if (ptr = malloc(size)) {
37         *ptr = (XeChar)NULL;   /* Force first byte to NULL for bozos who */
38                                /* think malloc zeros memory!             */
39         return ptr;
40     }
41     
42     _DtSimpleError(XeProgName, XeError,  XeString_NULL,
43                    "><DtEncap: cannot malloc memory");
44     exit(1);
45     return (void*)NULL;
46 }
47
48 /*-----------------------------------------------------------------------+*/
49 void XeFree( void * ptr )
50 /*-----------------------------------------------------------------------+*/
51 {
52     if (ptr) 
53         free((char *)ptr); 
54 }