This commit is contained in:
Gregory 2019-04-26 20:25:53 +03:00
parent 140635eb5f
commit fc088b2fa0

View file

@ -24,7 +24,16 @@ void *malloc(size_t size)
{ {
curr = prev->next; curr = prev->next;
if (curr->units >= nunits) if (curr->units >= nunits)
{
if (curr->units == nunits)
prev->next = curr->next; prev->next = curr->next;
else
{
curr->units -= nunits;
curr += curr->units;
curr->units = nunits;
}
}
prev = curr; prev = curr;
curr = curr->next; curr = curr->next;
} }