diff --git a/modules/src/alloc/st_alloc.c b/modules/src/alloc/st_alloc.c index 8ead24486..b8c6927b6 100644 --- a/modules/src/alloc/st_alloc.c +++ b/modules/src/alloc/st_alloc.c @@ -20,7 +20,12 @@ st_alloc(phead, size, count) char *retval; if (*phead == 0) { - p = Malloc(size * count); + while (count >= 1 && (p = malloc(size * count)) == 0) { + count >>= 1; + } + if (p == 0) { + No_Mem(); + } ((_PALLOC_) p)->_A_next = 0; while (--count) { p += size; diff --git a/modules/src/alloc/std_alloc.c b/modules/src/alloc/std_alloc.c index 334581c83..381ba4017 100644 --- a/modules/src/alloc/std_alloc.c +++ b/modules/src/alloc/std_alloc.c @@ -19,8 +19,12 @@ std_alloc(phead, size, count, pcnt) register char *p; if (*phead == 0) { - - p = Malloc(size * count); + while (count >= 1 && (p = malloc(size * count)) == 0) { + count >>= 1; + } + if (p == 0) { + No_Mem(); + } *pcnt += count; ((_PALLOC_) p)->_A_next = 0; while (--count) {