1 #ifndef VIRTMEM_STDIO_ALLOC_H
2 #define VIRTMEM_STDIO_ALLOC_H
27 template <
typename Properties = DefaultAllocProperties>
36 fprintf(stderr,
"Unable to open ram file!");
40 void doSuspend(
void) { }
41 void doStop(
void) {
if (ramFile) { fclose(ramFile); ramFile = 0; } }
44 if (fseek(ramFile, offset, SEEK_SET) != 0)
45 fprintf(stderr,
"fseek error: %s\n", strerror(errno));
47 fread(data, size, 1, ramFile);
49 fprintf(stderr,
"didn't read correctly: %s\n", strerror(errno));
55 if (fseek(ramFile, offset, SEEK_SET) != 0)
56 fprintf(stderr,
"fseek error: %s\n", strerror(errno));
58 fwrite(data, size, 1, ramFile);
60 fprintf(stderr,
"didn't write correctly: %s\n", strerror(errno));
77 #endif // VIRTMEM_STDIO_ALLOC_H
contains all code from virtmem
Definition: base_alloc.cpp:22
StdioVAllocP(VPtrSize ps=VIRTMEM_DEFAULT_POOLSIZE)
Constructs (but not initializes) the allocator.
Definition: stdio_alloc.h:69
void writeZeros(VPtrNum start, VPtrSize n)
Writes zeros to raw virtual memory. Can be used to initialize the memory pool.
Definition: base_alloc.cpp:489
Base template class for virtual memory allocators.
Definition: alloc.h:28
void setPoolSize(VPtrSize ps)
Sets the total size of the memory pool.
Definition: base_alloc.h:155
Virtual memory allocator that uses a regular file (via stdio) as memory pool.
Definition: stdio_alloc.h:28
This header file contains several variables that can be used to customize virtmem.
StdioVAllocP StdioVAlloc
Shortcut to StdioVAllocP with default template arguments.
Definition: stdio_alloc.h:73
virtual memory class header
uint32_t VPtrSize
Numeric type used to store the size of a virtual memory block.
Definition: base_alloc.h:22
VPtrSize getPoolSize(void) const
Returns the size the memory pool.
Definition: base_alloc.h:187
#define VIRTMEM_DEFAULT_POOLSIZE
The default poolsize for allocators supporting a variable sized pool.
Definition: config.h:55