9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6c78a717a2e6cde7c0a85e2e30fc7a58c938dd9b
parent 1b514694b7db293fee61cd36828ddf1e41a4f358
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date:   Fri, 18 Nov 2022 17:50:46 +0100

os9: Remove lockalloc code

Original code was dessigned to use malloc in the
initial configuration but as the code evolved this
decision was removed and this code remained.

Diffstat:
Msrc/os9/alloc.c | 20+++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/os9/alloc.c b/src/os9/alloc.c @@ -49,36 +49,30 @@ allocb(int n) void * alloc(size_t size) { - static int lockalloc; size_t n; static size_t used; static union bucket *heap; static mutex_t m; union bucket *bp = NULL; - lock(&m); if (size == 0) { - lockalloc = 1; - goto end; - } - - if (lockalloc) { - errno = 1; /* TODO: What can I do here???? */ - goto end; + errno = EINVAL; + return NULL; } + lock(&m); if (!heap) heap = allocb(HEAPSIZ); n = (size-1) / sizeof(union bucket) + 1; size = n * sizeof(union bucket); + if (used > SIZE_MAX - size) { errno = ENOMEM; - goto end; + } else { + bp = heap + used; + used += size; } - bp = heap + used; - used += size; -end: unlock(&m); return bp;