static void objDefine(objectTable table, void *logObj, void *obj, size_t size) { if (table != NULL) { Res ires; ires = TableDefine(table->startTable, (Word)logObj, obj); verify(ires == ResOK); if (table->endTable != NULL) { ires = TableDefine(table->endTable, (Word)PointerAdd(logObj, size), PointerAdd(obj, size)); verify(ires == ResOK); } } }
static void objRemove(void **objReturn, objectTable table, void *logObj, size_t size) { Bool found; Res ires; void *obj; void *end; void *logEnd; found = TableLookup(&obj, table->startTable, (Word)logObj); if (found) { ires = TableRemove(table->startTable, (Word)logObj); verify(ires == ResOK); if (table->endTable != NULL) { ires = TableRemove(table->endTable, (Word)PointerAdd(logObj, size)); verify(ires == ResOK); } *objReturn = obj; return; } /* Must be a truncation. */ verify(table->endTable != NULL); logEnd = PointerAdd(logObj, size); found = TableLookup(&end, table->endTable, (Word)logEnd); verify(found); obj = PointerSub(end, size); /* Remove the old end and insert the new one. */ ires = TableRemove(table->endTable, (Word)logEnd); verify(ires == ResOK); ires = TableDefine(table->endTable, (Word)logObj, obj); verify(ires == ResOK); *objReturn = obj; return; }
static void recordIntern(char *p) { ulongest_t stringId; char *string; char *copy; size_t len; Res res; stringId = parseHex(&p); string = parseString(&p); len = strlen(string); copy = malloc(len+1); if (copy == NULL) everror("Couldn't allocate space for a string."); (void)strcpy(copy, string); res = TableDefine(internTable, (Word)stringId, (void *)copy); if (res != ResOK) everror("Couldn't create an intern mapping."); }
static void recordLabel(char *p) { ulongest_t address; ulongest_t *stringIdP; Res res; address = parseHex(&p); if (address > (Word)-1) { printf("label address too large!"); return; } stringIdP = malloc(sizeof(ulongest_t)); if (stringIdP == NULL) everror("Can't allocate space for a string's ID"); *stringIdP = parseHex(&p); res = TableDefine(labelTable, (Word)address, (void *)stringIdP); if (res != ResOK) everror("Couldn't create an intern mapping."); }
Res ires; void *entry; Bool found; found = TableLookup(&entry, arenaTable, (Word)logArena); verify(found); va_start(args, bufferClassLevel); eres = mps_pool_create_v(&pool, (mps_arena_t)entry, class, args); verifyMPS(eres); va_end(args); rep = malloc(sizeof(poolRepStruct)); verify(rep != NULL); rep->pool = pool; rep->objects = objectTableCreate(support); rep->bufferClassLevel = bufferClassLevel; ires = TableDefine(poolTable, (Word)logPool, (void *)rep); verify(ires == ResOK); } /* poolRedestroy -- destroy and derecord a pool */ static void poolRedestroy(void *logPool) { Res ires; void *entry; Bool found; poolRep rep; found = TableLookup(&entry, poolTable, (Word)logPool); verify(found);