From 0066b478cf57efa0fdf3dbc2d44d113f3afd4910 Mon Sep 17 00:00:00 2001 From: Richard Tucker Date: Tue, 29 Sep 1998 14:40:02 +0100 Subject: [PATCH] Add new alloc function Copied from Perforce Change: 20149 ServerID: perforce.ravenbrook.com --- mps/qa/test/testlib/epvmfmt.c | 23 ++++++++++++++++------- mps/qa/test/testlib/epvmfmt.h | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/mps/qa/test/testlib/epvmfmt.c b/mps/qa/test/testlib/epvmfmt.c index ec20faee019..76a5487ae08 100644 --- a/mps/qa/test/testlib/epvmfmt.c +++ b/mps/qa/test/testlib/epvmfmt.c @@ -1,4 +1,4 @@ -/* $HopeName: MMQA_harness!testlib:epvmfmt.c(trunk.4) $ +/* $HopeName: MMQA_harness!testlib:epvmfmt.c(trunk.5) $ */ #include "mps.h" @@ -61,10 +61,16 @@ struct mps_fmt_A_s fmtepvm = */ psobj *allocepvm(mps_ap_t ap, int size) { + psobj *a; + die(allocrepvm(&a, ap, size), "Reserve: "); + return a; +} + +mps_res_t allocrepvm(psobj **q, mps_ap_t ap, int size) { mps_addr_t p; - psobj *q; int i; size_t bytes; + mps_res_t res; asserts(sizeof(struct psobj) == 8, "Aaarg! How can EPVM pools possibly work"); bytes = size*8; @@ -73,19 +79,22 @@ psobj *allocepvm(mps_ap_t ap, int size) { do { - die(mps_reserve(&p, ap, bytes), "Reserve: "); - q=p; + res = mps_reserve(&p, ap, bytes); + if (res != MPS_RES_OK) { + return res; + } + *q=p; for(i=0; iobj = NULL; - (q+i)->size = 0; + (*q+i)->obj = NULL; + (*q+i)->size = 0; } } while (!mps_commit(ap, p, bytes)); commentif(alloccomments, "allocated %p.", q); - return q; + return MPS_RES_OK; } void splatepvm(psobj *obj) { diff --git a/mps/qa/test/testlib/epvmfmt.h b/mps/qa/test/testlib/epvmfmt.h index 96a0982087c..1fe5c189514 100644 --- a/mps/qa/test/testlib/epvmfmt.h +++ b/mps/qa/test/testlib/epvmfmt.h @@ -1,4 +1,4 @@ -/* $HopeName$ +/* $HopeName: MMQA_harness!testlib:epvmfmt.h(trunk.3) $ epvmfmt.h Format for objects in the EPVM pool. */ @@ -30,6 +30,8 @@ extern struct mps_fmt_A_s fmtepvm; psobj *allocepvm(mps_ap_t ap, int words); +mps_res_t allocrepvm(psobj **, mps_ap_t ap, int words); + void splatepvm(psobj *obj); mps_bool_t issplatepvm(psobj *obj);