void ListAllocator::region(Address addr, Size size) { MemRegion *r = (MemRegion *) (addr); MemBlock *b = (MemBlock *) (addr + sizeof(MemRegion)); REVALIDATE(); /* Assume sane arguments. */ assert(size > sizeof(MemRegion) + sizeof(MemBlock)); assertRead(addr); assertWrite(addr); /* Initialize region. */ r->magic = LISTALLOC_MAGIC; r->size = size - sizeof(MemRegion) - sizeof(MemBlock); r->free = r->size; r->next = regions; r->blocks = b; /* Initialize block. */ b->magic = LISTALLOC_MAGIC; b->free = TRUE; b->prev = ZERO; b->next = ZERO; b->size = r->size; b->region = r; /* Make us the new regions head. */ regions = r; REVALIDATE(); }
void ListAllocator::release(Address addr) { MemBlock *b = (MemBlock *) (addr - sizeof(MemBlock)); REVALIDATE(); /* Sane block given? */ assertRead(addr); assertWrite(addr); assert(b->free != TRUE); assert(b->magic == LISTALLOC_MAGIC); assert(b->prev != b); assert(b->next != b); assert(b->region != ZERO); /* Mark free. */ b->free = TRUE; b->region->free += b->size; /* Merge with previous. */ if (b->prev && b->prev->free) { b->prev->size += (b->size + sizeof(MemBlock)); b->prev->next = b->next; if (b->next) b->next->prev = b->prev; REVALIDATE(); } /* Merge with next */ else if (b->next && b->next->free) { b->size += (b->next->size + sizeof(MemBlock)); if (b->next->next) b->next->next->prev = b; b->next = b->next->next; REVALIDATE(); } REVALIDATE(); }
bool String::operator == (char *ch) { assertRead(ch); return strcmp(value, ch) == 0; }
bool String::operator == (String *s) { assertRead(s); return strcmp(value, s->value) == 0; }
void String::operator = (const char *s) { assertRead(s); this->value = (char *) s; }
void String::operator = (String *s) { assertRead(s); assertRead(s->value); this->value = s->value; }
bool String::equals(const String & s) { assertRead(s.value); return strcmp(value, s.value) == 0; }
bool String::equals(String *s) { assertRead(s->value); return strcmp(value, s->value) == 0; }