diff --git a/mps/code/format.c b/mps/code/format.c index fc369f6a4ba..69e7ff1ddbe 100644 --- a/mps/code/format.c +++ b/mps/code/format.c @@ -22,7 +22,6 @@ Bool FormatCheck(Format format) CHECKU(Arena, format->arena); CHECKL(format->serial < format->arena->formatSerial); CHECKD_NOSIG(Ring, &format->arenaRing); - CHECKD_NOSIG(Ring, &format->poolRing); CHECKL(AlignCheck(format->alignment)); /* TODO: Define the concept of the maximum alignment it is possible to request from the MPS, document and provide an interface to it, and then @@ -142,7 +141,7 @@ Res FormatCreate(Format *formatReturn, Arena arena, ArgList args) format->arena = arena; RingInit(&format->arenaRing); - RingInit(&format->poolRing); + format->poolCount = 0; format->alignment = fmtAlign; format->headerSize = fmtHeaderSize; format->scan = fmtScan; @@ -170,14 +169,13 @@ Res FormatCreate(Format *formatReturn, Arena arena, ArgList args) void FormatDestroy(Format format) { AVERT(Format, format); - AVER(RingIsSingle(&format->poolRing)); + AVER(format->poolCount == 0); RingRemove(&format->arenaRing); format->sig = SigInvalid; RingFinish(&format->arenaRing); - RingFinish(&format->poolRing); ControlFree(format->arena, format, sizeof(FormatStruct)); } diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index 62d82d658ce..2885f193d31 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h @@ -110,7 +110,6 @@ typedef struct mps_pool_s { /* generic structure */ RingStruct segRing; /* segs are attached to pool */ Align alignment; /* alignment for units */ Format format; /* format only if class->attr&AttrFMT */ - RingStruct formatRing; /* link in list of pools using format */ PoolFixMethod fix; /* fix method */ double fillMutatorSize; /* bytes filled, mutator buffers */ double emptyMutatorSize; /* bytes emptied, mutator buffers */ @@ -411,7 +410,7 @@ typedef struct mps_fmt_s { Serial serial; /* from arena->formatSerial */ Arena arena; /* owning arena */ RingStruct arenaRing; /* formats are attached to the arena */ - RingStruct poolRing; /* ring of pools using the format */ + Count poolCount; /* number of pools using the format */ Align alignment; /* alignment of formatted objects */ mps_fmt_scan_t scan; mps_fmt_skip_t skip; diff --git a/mps/code/pool.c b/mps/code/pool.c index 96f853eb94b..2e59c08a69a 100644 --- a/mps/code/pool.c +++ b/mps/code/pool.c @@ -153,7 +153,6 @@ Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args) RingInit(&pool->arenaRing); RingInit(&pool->bufferRing); RingInit(&pool->segRing); - RingInit(&pool->formatRing); pool->bufferSerial = (Serial)0; pool->alignment = MPS_PF_ALIGN; pool->format = NULL; @@ -180,14 +179,13 @@ Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args) /* Add initialized pool to list of pools using format. */ if (pool->format) { - RingAppend(&pool->format->poolRing, &pool->formatRing); + ++ pool->format->poolCount; } return ResOK; failInit: pool->sig = SigInvalid; /* Leave arena->poolSerial incremented */ - RingFinish(&pool->formatRing); RingFinish(&pool->segRing); RingFinish(&pool->bufferRing); RingFinish(&pool->arenaRing); @@ -247,11 +245,11 @@ void PoolFinish(Pool pool) /* Detach the pool from the arena and format, and unsig it. */ RingRemove(&pool->arenaRing); if (pool->format) { - RingRemove(&pool->formatRing); + AVER(pool->format->poolCount > 0); + -- pool->format->poolCount; } pool->sig = SigInvalid; - RingFinish(&pool->formatRing); RingFinish(&pool->segRing); RingFinish(&pool->bufferRing); RingFinish(&pool->arenaRing); diff --git a/mps/test/conerr/12.c b/mps/test/conerr/12.c index f904f1e3267..139abce195b 100644 --- a/mps/test/conerr/12.c +++ b/mps/test/conerr/12.c @@ -7,7 +7,7 @@ TEST_HEADER OUTPUT_SPEC assert = true assertfile P= format.c - assertcond = RingIsSingle(&format->poolRing) + assertcond = format->poolCount == 0 END_HEADER */