lib/std/memory.cc
// Creates a new chunk, leaving the previous one with offset + sizeof(struct
// chunk_header) bytes.
Creates a new chunk, leaving the previous one with offset + sizeof(struct
chunk_header) bytes.
Creates a new chunk leaving the previous one with offset + sizeof ( struct chunk_header ) bytes .
struct chunk_header *insert_chunk(struct chunk_header *prev, size_t offset) {
  struct chunk_header *new_chunk =
      (struct chunk_header *)((char *)prev + sizeof(struct chunk_header) +
                              offset);
  new_chunk->size = prev->size - sizeof(struct chunk_header) - offset;
  new_chunk->allocated = 0;
  new_chunk->prev = prev;
  new_chunk->next = prev->next;
  new_chunk->next->prev = new_chunk;
  prev->size = offset + sizeof(struct chunk_header);
  prev->next = new_chunk;
  prev->checksum = checksum(prev);
  new_chunk->checksum = checksum(new_chunk);
  new_chunk->next->checksum = checksum(new_chunk->next);
  return new_chunk;
}
struct chunk_header * insert_chunk ( struct chunk_header * prev , size_t offset ) { struct chunk_header * new_chunk = ( struct chunk_header * ) ( ( char * ) prev + sizeof ( struct chunk_header ) + offset ) ; new_chunk -> size = prev -> size - sizeof ( struct chunk_header ) - offset ; new_chunk -> allocated = 0 ; new_chunk -> prev = prev ; new_chunk -> next = prev -> next ; new_chunk -> next -> prev = new_chunk ; prev -> size = offset + sizeof ( struct chunk_header ) ; prev -> next = new_chunk ; prev -> checksum = checksum ( prev ) ; new_chunk -> checksum = checksum ( new_chunk ) ; new_chunk -> next -> checksum = checksum ( new_chunk -> next ) ; return new_chunk ; }
Creates a new chunk, leaving the previous one with offset + sizeof(struct
chunk_header) bytes.
Creates a new chunk leaving the previous one with offset + sizeof ( struct chunk_header ) bytes .