Files
Arquivotheca.Solaris-2.5/cmd/zdump/ialloc.c
seta75D 7c4988eac0 Init
2021-10-11 19:38:01 -03:00

115 lines
2.3 KiB
C
Executable File

/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ialloc.c 1.4 92/07/14 SMI" /* SVr4.0 1.1 */
/*******************************************************************
PROPRIETARY NOTICE (Combined)
This source code is unpublished proprietary information
constituting, or derived under license from AT&T's UNIX(r) System V.
In addition, portions of such source code were derived from Berkeley
4.3 BSD under license from the Regents of the University of
California.
Copyright Notice
Notice of copyright on this source code product does not indicate
publication.
(c) 1986,1987,1988,1989 Sun Microsystems, Inc
(c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
All rights reserved.
********************************************************************/
#include <stdio.h>
#include <string.h>
#ifndef alloc_t
#define alloc_t unsigned
#endif /* !alloc_t */
#ifdef MAL
#define NULLMAL(x) ((x) == NULL || (x) == MAL)
#else /* !MAL */
#define NULLMAL(x) ((x) == NULL)
#endif /* !MAL */
extern char * calloc();
extern char * malloc();
extern char * realloc();
char *
imalloc(n)
{
#ifdef MAL
register char * result;
if (n == 0)
n = 1;
result = malloc((alloc_t) n);
return (result == MAL) ? NULL : result;
#else /* !MAL */
if (n == 0)
n = 1;
return malloc((alloc_t) n);
#endif /* !MAL */
}
char *
icalloc(nelem, elsize)
{
if (nelem == 0 || elsize == 0)
nelem = elsize = 1;
return calloc((alloc_t) nelem, (alloc_t) elsize);
}
char *
irealloc(pointer, size)
char * pointer;
{
if (NULLMAL(pointer))
return imalloc(size);
if (size == 0)
size = 1;
return realloc(pointer, (alloc_t) size);
}
char *
icatalloc(old, new)
char * old;
char * new;
{
register char * result;
register oldsize, newsize;
oldsize = NULLMAL(old) ? 0 : strlen(old);
newsize = NULLMAL(new) ? 0 : strlen(new);
if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
if (!NULLMAL(new))
(void) strcpy(result + oldsize, new);
return result;
}
char *
icpyalloc(string)
char * string;
{
return icatalloc((char *) NULL, string);
}
ifree(p)
char * p;
{
if (!NULLMAL(p))
free(p);
}