18 static size_t mem_read(
io_t *
self, 
void *dst, 
size_t size)
 
   27 static size_t mem_write(
io_t *
self, 
const void *src, 
size_t size)
 
   43 static size_t mem_size(
io_t *
self)
 
   49 static size_t mem_seek(
io_t *
self, 
size_t offset)
 
   58     CTASSERTF(!(protect & eOsProtectExecute), 
"cannot map memory object as executable `%s`", 
io_name(
self));
 
   65 static os_error_t mem_close(
io_t *
self)
 
   75     .fn_write = mem_write,
 
   77     .fn_get_size = mem_size,
 
   81     .fn_close = mem_close,
 
   86 static io_t *impl_memory_init(
void *buffer, 
const char *name, 
const void *data, 
size_t size, 
os_access_t flags, 
arena_t *arena)
 
   99     return io_init(buffer, &kBufferCallbacks, flags, name, &impl, arena);
 
  111     return io_init(buffer, &kBufferCallbacks, flags, name, &impl, arena);
 
  122     return impl_memory_init(buffer, name, data, 
size, flags, arena);
 
  129     return impl_blob_init(buffer, name, 
size, flags, arena);
 
  139     return impl_memory_init(buffer, name, data, 
size, flags, arena);
 
  145     return impl_blob_init(buffer, name, 
size, flags, arena);
 
STA_DECL io_t * io_blob(const char *name, size_t size, os_access_t flags, arena_t *arena)
create an IO object in memory of a given size size specifies the initial internal buffer size,...
 
STA_DECL io_t * io_memory(const char *name, const void *data, size_t size, os_access_t flags, arena_t *arena)
create an IO object from an initial view of memory
 
STA_DECL io_t * io_blob_init(void *buffer, const char *name, size_t size, os_access_t flags, arena_t *arena)
 
STA_DECL io_t * io_memory_init(void *buffer, const char *name, const void *data, size_t size, os_access_t flags, arena_t *arena)
 
os_protect_t
file mapping memory protection
 
os_access_t
file access mode
 
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
 
CT_NOALIAS CT_BASE_API void * ctu_memcpy(STA_WRITES(size) void *CT_RESTRICT dst, STA_READS(size) const void *CT_RESTRICT src, size_t size)
copy memory from one location to another equivalent to memcpy but with safety checks
 
CT_PUREFN CT_IO_API void * io_data(io_t *io)
get the user data from an io object
 
CT_IO_API io_t * io_init(STA_WRITES(sizeof(io_t)+cb->size) void *buffer, const io_callbacks_t *cb, os_access_t flags, const char *name, STA_READS(cb->size) const void *data, arena_t *arena)
initialize an IO object for a given interface
 
CT_NODISCARD CT_IO_API const char * io_name(const io_t *io)
get the name of an io object
 
CT_NODISCARD CT_ARENA_API void * arena_realloc(STA_RELEASE void *ptr, size_t new_size, size_t old_size, arena_t *arena)
resize a memory allocation from a custom allocator
 
#define ARENA_MALLOC(size, name, parent, arena)
allocate memory from a custom allocator
 
CT_ARENA_API void arena_free(STA_RELEASE void *ptr, size_t size, arena_t *arena)
release memory from a custom allocator
 
#define CTASSERT(expr)
assert a condition, prints the condition as a message
 
#define CTASSERTF(expr,...)
assert a condition with a message and optional format arguments
 
a read/write in memory file
 
size_t total
total size of data
 
size_t offset
current offset in data
 
io_read_t fn_read
read callback may be NULL on non-readable objects