3 #ifndef __FILE_ALLOCATOR_H__
4 #define __FILE_ALLOCATOR_H__
10 #include "storage/StorageTypes.h"
114 bool dump(
int level=1, FILE *out=stdout);
152 { bytes = new_bytes; }
155 void addBytes(
int bytes_to_add);
192 Node allocated_head, free_head;
195 void remove_node(Node &head,
const Node &node);
197 void insert_node(Node &head,
~FileAllocator()
Destructor checks if detach has been called.
FileOffset allocate(FileOffset num_bytes)
Allocate a block with given size, returning a file offset (for fseek).
static FileOffset minimum_size
To avoid allocating tiny areas, also to avoid splitting free blocks into pieces that are then too sma...
Definition: FileAllocator.h:93
bool attach(FILE *f, FileOffset reserved_space, bool init)
Must be invoked to attach (& initialize) a file.
static FileOffset file_size_increment
Setting file_size_increment will cause the file size to jump in the given increments.
Definition: FileAllocator.h:97
FileOffset size() const
Definition: FileAllocator.h:73
FileAllocator()
Constructor/destructor check if attach/detach have been called.
uint32_t FileOffset
FileOffset is used as a system independent type for, well, offsets into files.
Definition: StorageTypes.h:13
void detach()
Must be called before destroying the FileAllocator and closing the file.
Maintains memory blocks within a file.
Definition: FileAllocator.h:22
void free(FileOffset offset)
Release a file block (will be placed in free list).
bool dump(int level=1, FILE *out=stdout)
Show ASCII-type info about the file structure.