copyright messages
[unix-history] / usr / src / usr.bin / window / wwalloc.c
#ifndef lint
static char sccsid[] = "@(#)wwalloc.c 3.7 %G%";
#endif
/*
* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
*/
#include "ww.h"
char **
wwalloc(row, col, nrow, ncol, size)
{
register char *p, **pp;
register int i;
/* fast, call malloc only once */
pp = (char **)
malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
if (pp == 0) {
wwerrno = WWE_NOMEM;
return 0;
}
p = (char *)&pp[nrow];
col *= size;
size /= sizeof (char); /* paranoid */
size *= ncol;
for (i = 0; i < nrow; i++) {
pp[i] = p - col;
p += size;
}
return pp - row;
}
wwfree(p, row)
register char **p;
{
free((char *)(p + row));
}