diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-15 13:03:11 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-15 13:03:11 +0000 |
commit | d464a1d3a62d620b6336131c355467bdc273e3c5 (patch) | |
tree | f1e495cbff84173fea0bb238bfb01e509ab524fe /memory.c | |
parent | 65f7f8c1f339e11ed7867eb1c19fa4692976221a (diff) |
Rework printer to add vertical padding too
Diffstat (limited to 'memory.c')
-rw-r--r-- | memory.c | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -1,10 +1,32 @@ #include <u.h> #include <libc.h> #include <bio.h> +#include <pool.h> #include "apl9.h" int alloccounts = 0; +int debugmem; + +void * +emalloc(ulong size) +{ + void *res = malloc(size); + if(res == nil){ + print("Out of memory! :(\n"); + exits("emalloc"); + } + return res; +} + +void +checkmem(char *where) +{ + if(debugmem){ + print("Checking memory at: %s\n", where); + poolcheck(mainmem); + } +} void freearray(Array *a) @@ -32,13 +54,13 @@ freearray(Array *a) Array * allocarray(arrayDataType t, int rank, int size) { - Array *a = malloc(sizeof(Array)); + Array *a = emalloc(sizeof(Array)); a->rank = rank; a->type = t; a->size = size; a->stranded = 0; - a->shape = malloc(sizeof(int) * rank); - a->rawdata = malloc(datasizes[t] * size); + a->shape = emalloc(sizeof(int) * rank); + a->rawdata = emalloc(datasizes[t] * size); a->type = t; a->refs = 1; alloccounts++; |