From e425895a315d65ff9ca1e2d7911c2fd21d49fe5e Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 9 May 2022 18:59:23 +0000 Subject: =?UTF-8?q?Fix=20some=20nasty=20bugs=20with=20empty=20lines=20in?= =?UTF-8?q?=20dfns,=20and=20with=20stranding=20of=20=E2=8D=BA=20and=20?= =?UTF-8?q?=E2=8D=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- concurrency.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'concurrency.c') diff --git a/concurrency.c b/concurrency.c index 81ff7b1..1d06a9c 100644 --- a/concurrency.c +++ b/concurrency.c @@ -49,7 +49,7 @@ spawnthread(Function f, Array *left, Array *right) */ Channel *setupdone = chancreate(sizeof(int), 0); SpawnData *sp = emalloc(sizeof(SpawnData)); - sp->func = f; + sp->func = dupfunction(f); sp->left = left ? duparray(left) : nil; sp->right = duparray(right); sp->setupdone = setupdone; @@ -87,6 +87,8 @@ messagesend(Array *a, int id) td->lastmail = newmail; rwakeup(&td->empty); qunlock(&td->lock); + }else{ + throwerror(L"Invalid thread id", EDomain); } } @@ -134,6 +136,7 @@ newprocfn(void *data) unlock(&threadlock); freearray(sp->left); freearray(sp->right); + freefunction(sp->func); free(sp); free(td); } -- cgit v1.2.3