From fc088b2fa089bc7d634589e1a58edebfa7b83cad Mon Sep 17 00:00:00 2001 From: Gregory Date: Fri, 26 Apr 2019 20:25:53 +0300 Subject: [PATCH] malllloc --- src/malloc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/malloc.c b/src/malloc.c index 39fdfc5..31ee2f6 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -24,7 +24,16 @@ void *malloc(size_t size) { curr = prev->next; if (curr->units >= nunits) - prev->next = curr->next; + { + if (curr->units == nunits) + prev->next = curr->next; + else + { + curr->units -= nunits; + curr += curr->units; + curr->units = nunits; + } + } prev = curr; curr = curr->next; }