xref: /original-bsd/old/lib2648/newmat.c (revision e59fb703)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)newmat.c	5.1 (Berkeley) 04/26/85";
9 #endif not lint
10 
11 /*
12  * newmat: return a brand new bitmat with the proper size.
13  * To get rid of it just call free.
14  */
15 
16 #include "bit.h"
17 
18 bitmat
19 newmat(rows, cols)
20 int rows, cols;
21 {
22 	int size = ((cols + 7) >> 3) * rows;
23 	char *m;
24 
25 #ifdef TRACE
26 	if (size <= 0 && trace) {
27 		fprintf(trace, "newmat: rows=%d, cols=%d\n", rows, cols);
28 		abort();
29 	}
30 	if (trace)
31 		fprintf(trace, "newmat: malloc(%d) =", size);
32 #endif
33 	m = (char *) malloc(size);
34 #ifdef TRACE
35 	if (trace)
36 		fprintf(trace, "%x\n", m);
37 #endif
38 	zermat(m, rows, cols);
39 	return (m);
40 }
41