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