diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2022-02-09 01:16:03 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2022-02-09 01:16:03 +0000 |
commit | 6ed5b9f6d3fdeeed8ecd43b18bae642ec1ec24b1 (patch) | |
tree | cee3f787af7fb7e8b892fb661f63dc9248cd5f61 /concurrency.c | |
parent | 8fd005f6185ac76ed0ac2495bd97ee817b472040 (diff) |
Add much better memory handling (We now track and free Datum * structs)
Diffstat (limited to 'concurrency.c')
-rw-r--r-- | concurrency.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/concurrency.c b/concurrency.c index 4af563c..c393884 100644 --- a/concurrency.c +++ b/concurrency.c @@ -4,7 +4,7 @@ #include <bio.h> #include "apl9.h" -#define STACKSIZE (8*1024*1024) /* 8 MB */ +#define STACKSIZE (8*1024*1024) /* 64 MB */ typedef struct SpawnData SpawnData; struct SpawnData @@ -48,7 +48,7 @@ spawnthread(Function f, Array *left, Array *right) exit proc */ Channel *setupdone = chancreate(sizeof(int), 0); - SpawnData *sp = malloc(sizeof(SpawnData)); + SpawnData *sp = emalloc(sizeof(SpawnData)); sp->func = f; sp->left = left ? duparray(left) : nil; sp->right = duparray(right); @@ -77,7 +77,7 @@ messagesend(Array *a, int id) unlock(&threadlock); if(td != nil){ qlock(&td->lock); - Mail *newmail = malloc(sizeof(Mail)); + Mail *newmail = emalloc(sizeof(Mail)); newmail->contents = fnSame(a); newmail->next = 0; if(td->lastmail != nil) @@ -132,7 +132,7 @@ newprocfn(void *data) static ThreadData * newthreaddata(void) { - ThreadData *td = mallocz(sizeof(ThreadData), 1); + ThreadData *td = emallocz(sizeof(ThreadData), 1); td->id = threadid(); td->currentdfn = nil; td->mail = 0; @@ -141,7 +141,7 @@ newthreaddata(void) lock(&threadlock); nthreads++; - threads = realloc(threads, sizeof(ThreadData *) * nthreads); + threads = erealloc(threads, sizeof(ThreadData *) * nthreads); threads[nthreads-1] = td; unlock(&threadlock); return td; |