| 1 | /* newmat.c 4.1 83/03/09 */ |
| 2 | /* |
| 3 | * newmat: return a brand new bitmat with the proper size. |
| 4 | * To get rid of it just call free. |
| 5 | */ |
| 6 | |
| 7 | #include "bit.h" |
| 8 | |
| 9 | bitmat |
| 10 | newmat(rows, cols) |
| 11 | int rows, cols; |
| 12 | { |
| 13 | int size = ((cols + 7) >> 3) * rows; |
| 14 | char *m; |
| 15 | |
| 16 | #ifdef TRACE |
| 17 | if (size <= 0 && trace) { |
| 18 | fprintf(trace, "newmat: rows=%d, cols=%d\n", rows, cols); |
| 19 | abort(); |
| 20 | } |
| 21 | if (trace) |
| 22 | fprintf(trace, "newmat: malloc(%d) =", size); |
| 23 | #endif |
| 24 | m = (char *) malloc(size); |
| 25 | #ifdef TRACE |
| 26 | if (trace) |
| 27 | fprintf(trace, "%x\n", m); |
| 28 | #endif |
| 29 | zermat(m, rows, cols); |
| 30 | return (m); |
| 31 | } |