#include <virtmem.h>
Collaboration diagram for Chunk:
Public Methods | |
void | set_size (unsigned int chunk_size, bool previous_in_use, bool next_in_use) |
void | set_previous_in_use (bool previous_in_use) |
void | set_next_in_use (bool next_in_use) |
unsigned int | size () |
unsigned int | previous_size () |
Chunk * | previous_chunk () |
Chunk * | next_chunk () |
bool | is_previous_in_use () |
bool | is_next_in_use () |
void * | data_address () |
Static Public Methods | |
Chunk * | convert_data_address_to_chunk (void *data_address) |
unsigned int | align (unsigned int byte_size) |
void * | align (void *address) |
Public Attributes | |
Chunk * | forward |
Chunk * | back |
Static Public Attributes | |
const unsigned int | PREV_IN_USE = 1<<0 |
const unsigned int | NEXT_IN_USE = 1<<1 |
const unsigned int | STATUS_MASK = PREV_IN_USE | NEXT_IN_USE |
const unsigned int | SIZE_MASK = ~STATUS_MASK |
const unsigned int | ALIGNMENT = sizeof(unsigned int) - 1 |
const unsigned int | USED_HEADER_SIZE = sizeof(unsigned int) |
const unsigned int | UNUSED_HEADER_SIZE |
const unsigned int | FOOTER_SIZE = sizeof(unsigned int) |
Protected Attributes | |
unsigned int | size_and_flags |
|
Return the given address, properly byte aligned.
|
|
Return the given value rounded up the proper byte alignment value.
|
|
Given the address of the start of usable data within an allocated chunk, return the chunk itself.
|
|
Return the address of where the usable allocated data actually starts (only valid if this chunk is used / allocated).
|
|
Return whether the next chunk is in use (allocated).
|
|
Return whether the previous chunk is in use (allocated).
|
|
Return the address of the chunk immediately following this one in memory.
|
|
Return the address of the chunk immediately preceding this one in memory.
|
|
Return the size of the chunk immediately preceding this one in memory.
|
|
Set a flag indicating whether the next chunk is in use (allocated).
|
|
Set a flag indicating whether the previous chunk is in use (allocated).
|
|
Set this chunk's size and flags.
|
|
Return this chunk's size (including meta-data size).
|
|
|
|
prior unallocated chunk in list (only valid if this chunk is unused).
|
|
|
|
next unallocated chunk in list (only valid if this chunk is unused).
|
|
|
|
|
|
low bit 0: is previous chunk in use, low bit 1: is next chunk in use, rest of bits: size of this chunk.
|
|
|
|
|
|
Initial value: USED_HEADER_SIZE + sizeof(Chunk*) * 2 |
|
|
Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman