diff --git a/platforms/msdos/extras.c b/platforms/msdos/extras.c index 8a06be3..ecbf84a 100644 --- a/platforms/msdos/extras.c +++ b/platforms/msdos/extras.c @@ -36,15 +36,21 @@ time_t time(time_t *t) void *malloc(size_t v) { - static char heap[4096]; + static char heap[5000]; static char *heap_ptr = heap; char *old_heap_ptr; - old_heap_ptr = heap_ptr; - heap_ptr += v; + if (sizeof(heap) - (heap_ptr - heap) < v) { + asm __volatile("int $16\n" + "jmp exit" + : + : "a"((uint16_t)0)); - if (heap_ptr > heap + sizeof(heap)) return NULL; + } + + old_heap_ptr = heap_ptr; + heap_ptr += v; return old_heap_ptr; }