From d120b2b73a3b09a445dd6fedaef471d41df568fa Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 6 Jul 1987 13:03:14 +0000 Subject: [PATCH] tried to make faster --- mach/sun2/cv/cv.c | 18 ++++++++++-------- mach/sun3/cv/cv.c | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/mach/sun2/cv/cv.c b/mach/sun2/cv/cv.c index 95ec25d8b..4d310c028 100644 --- a/mach/sun2/cv/cv.c +++ b/mach/sun2/cv/cv.c @@ -261,13 +261,13 @@ writef(addr,sz,cnt) */ emits(section) struct outsect *section ; { char *p; - char *calloc(); + char *calloc(), *malloc(); long sz = section->os_flen; rd_outsect(section - outsect); while (sz) { unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (!(p = calloc(i, 1))) { + if (!(p = malloc(i))) { fatal("No memory.\n"); } rd_emit(p, i); @@ -279,16 +279,18 @@ emits(section) struct outsect *section ; { } sz = section->os_size - section->os_flen; - while (sz) { - unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (!(p = calloc(i, 1))) { + if (sz) { + if (!(p = calloc(0x4000, 1))) { fatal("No memory.\n"); } - if (write(output, p, i) < i) { - fatal("write error.\n"); + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + sz -= i; } free(p); - sz -= i; } } diff --git a/mach/sun3/cv/cv.c b/mach/sun3/cv/cv.c index 95ec25d8b..4d310c028 100644 --- a/mach/sun3/cv/cv.c +++ b/mach/sun3/cv/cv.c @@ -261,13 +261,13 @@ writef(addr,sz,cnt) */ emits(section) struct outsect *section ; { char *p; - char *calloc(); + char *calloc(), *malloc(); long sz = section->os_flen; rd_outsect(section - outsect); while (sz) { unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (!(p = calloc(i, 1))) { + if (!(p = malloc(i))) { fatal("No memory.\n"); } rd_emit(p, i); @@ -279,16 +279,18 @@ emits(section) struct outsect *section ; { } sz = section->os_size - section->os_flen; - while (sz) { - unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (!(p = calloc(i, 1))) { + if (sz) { + if (!(p = calloc(0x4000, 1))) { fatal("No memory.\n"); } - if (write(output, p, i) < i) { - fatal("write error.\n"); + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + sz -= i; } free(p); - sz -= i; } }