ScrnBuf Allocate (nrow, ncol, addr)  register int nrow, ncol; Char **addr;
ScrnBuf Allocate (register int nrow, register int ncol, Char **addr)
ScrnBuf Allocate (nrow, ncol, addr)/* * Allocates memory for a 2-dimensional array of chars and returns a pointer * thereto.  Each line is formed from a set of char arrays, with an index * (i.e., the ScrnBuf type).  The first pointer in the index is reserved for * per-line flags, and does not point to data. * * After the per-line flags, we have a series of pointers to char arrays:  The * first one is the actual character array, the second one is the attributes, * the third is the foreground and background colors, and the fourth denotes * the character set. * * We store it all as pointers, because of alignment considerations, together * with the intention of being able to change the total number of pointers per * row according to whether the user wants color or not. */register int nrow, ncol;Char **addr;{	register ScrnBuf base;	register Char *tmp;	register int i, j, k;	size_t entries = MAX_PTRS * nrow;	size_t length  = BUF_PTRS * nrow * ncol;	if ((base = (ScrnBuf) calloc (entries, sizeof (char *))) == 0)		SysError (ERROR_SCALLOC);	if ((tmp = (Char *)calloc (length, sizeof(Char))) == 0)		SysError (ERROR_SCALLOC2);	*addr = tmp;	for (i = k = 0; i < nrow; i++) {		base[k] = 0;	/* per-line flags */		k += BUF_HEAD;		for (j = BUF_HEAD; j < MAX_PTRS; j++) {			base[k++] = tmp;			tmp += ncol;		}	}	return (base);}