void BufferDestroy(Buffer buffer) { Arena arena; Size size; AVERT(Buffer, buffer); arena = buffer->arena; size = ClassOfPoly(Buffer, buffer)->size; BufferFinish(buffer); ControlFree(arena, buffer, size); }
void PoolDestroy(Pool pool) { Arena arena; Size size; AVERT(Pool, pool); arena = pool->arena; size = ClassOfPoly(Pool, pool)->size; PoolFinish(pool); /* .space.free: Free the pool instance structure. See .space.alloc */ ControlFree(arena, pool, size); }
Res InstDescribe(Inst inst, mps_lib_FILE *stream, Count depth) { InstClass klass; if (!TESTC(Inst, inst)) return ResPARAM; if (stream == NULL) return ResPARAM; klass = ClassOfPoly(Inst, inst); return WriteF(stream, depth, "$S $P\n", (WriteFS)ClassName(klass), inst, NULL); }
Res PoolInit(Pool pool, Arena arena, PoolClass klass, ArgList args) { Res res; AVERT(PoolClass, klass); res = klass->init(pool, arena, klass, args); if (res != ResOK) return res; EVENT3(PoolInit, pool, PoolArena(pool), ClassOfPoly(Pool, pool)); return ResOK; }
Bool PoolCheck(Pool pool) { PoolClass klass; /* Checks ordered as per struct decl in <code/mpmst.h#pool> */ CHECKS(Pool, pool); CHECKC(AbstractPool, pool); /* Break modularity for checking efficiency */ CHECKL(pool->serial < ArenaGlobals(pool->arena)->poolSerial); klass = ClassOfPoly(Pool, pool); CHECKD(PoolClass, klass); CHECKU(Arena, pool->arena); CHECKD_NOSIG(Ring, &pool->arenaRing); CHECKD_NOSIG(Ring, &pool->bufferRing); /* Cannot check pool->bufferSerial */ CHECKD_NOSIG(Ring, &pool->segRing); CHECKL(AlignCheck(pool->alignment)); /* Normally pool->format iff PoolHasAttr(pool, AttrFMT), but during pool initialization the class may not yet be set. */ CHECKL(!PoolHasAttr(pool, AttrFMT) || pool->format != NULL); return TRUE; }
void SegFree(Seg seg) { Arena arena; Pool pool; Addr base; Size size, structSize; AVERT(Seg, seg); pool = SegPool(seg); AVERT(Pool, pool); arena = PoolArena(pool); AVERT(Arena, arena); base = SegBase(seg); size = SegSize(seg); structSize = ClassOfPoly(Seg, seg)->size; SegFinish(seg); ControlFree(arena, seg, structSize); ArenaFree(base, size, pool); EVENT2(SegFree, arena, seg); }