File:  [Research Unix] / researchv10no / cmd / asd / alloc.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/*
 *	storage allocator
 *
 *	calls malloc or realloc and aborts if unsuccessful
 */

#include "asd.h"
#include <stdio.h>

char *malloc(), *realloc();

char *
alloc (n)
	unsigned n;
{
	register char *p;

	p = malloc (n);
	schk (p);
	return p;
}

char *
ralloc (s, n)
	char *s;
	unsigned n;
{
	register char *p;

	if (s == NULL)
		return alloc (n);
	
	p = realloc (s, n);
	schk (p);
	return p;
}

/* return a copy of a string */
char *
copy (s)
	register char *s;
{
	register char *r;
	r = alloc ((unsigned) (strlen (s) + 1));
	strcpy (r, s);
	return r;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.