|
|
1.1 root 1: /* $Header: Alloc.c,v 1.1 87/09/11 07:57:05 toddb Exp $ */
2: #ifndef lint
3: static char *sccsid = "@(#)Alloc.c 1.5 2/24/87";
4: #endif lint
5:
6: /*
7: * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
8: *
9: * All Rights Reserved
10: *
11: * Permission to use, copy, modify, and distribute this software and its
12: * documentation for any purpose and without fee is hereby granted,
13: * provided that the above copyright notice appear in all copies and that
14: * both that copyright notice and this permission notice appear in
15: * supporting documentation, and that the name of Digital Equipment
16: * Corporation not be used in advertising or publicity pertaining to
17: * distribution of the software without specific, written prior permission.
18: *
19: *
20: * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21: * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
22: * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23: * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24: * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25: * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
26: * SOFTWARE.
27: */
28:
29: /*
30: * X Toolkit Memory Allocation Routines
31: */
32: extern char *malloc(), *realloc(), *calloc();
33: extern void exit(), free();
34: #include "Xlib.h"
35: #include "Intrinsic.h"
36:
37: char *XtMalloc(size)
38: unsigned size;
39: {
40: char *ptr;
41:
42: if ((ptr = malloc(size)) == NULL)
43: XtErrorFunction(XtNOMEM);
44: return(ptr);
45: }
46:
47: char *XtRealloc(ptr, size)
48: char *ptr;
49: unsigned size;
50: {
51: if (ptr == NULL)
52: return(XtMalloc(size));
53: else if ((ptr = realloc(ptr, size)) == NULL)
54: XtErrorFunction(XtNOMEM);
55: return(ptr);
56: }
57:
58: char *XtCalloc(num, size)
59: unsigned num, size;
60: {
61: char *ptr;
62:
63: if ((ptr = calloc(num, size)) == NULL)
64: XtErrorFunction(XtNOMEM);
65: return(ptr);
66: }
67:
68: void XtFree(ptr)
69: char *ptr;
70: {
71: if (ptr != NULL) free(ptr);
72: }
73:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.