25 return io_init(buffer, cb, flags, name, data, arena);
35 if (flags & eOsAccessWrite)
36 CTASSERTF(cb->
fn_write != NULL,
"%s provided no `fn_write` function for a writable object",
39 if (flags & eOsAccessRead)
40 CTASSERTF(cb->
fn_read != NULL,
"%s provided no `fn_read` for a readable object", name);
STA_DECL io_t * io_init(void *buffer, const io_callbacks_t *cb, os_access_t flags, const char *name, const void *data, arena_t *arena)
STA_DECL io_t * io_new(const io_callbacks_t *cb, os_access_t flags, const char *name, const void *data, arena_t *arena)
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
STA_DECL void * io_data(io_t *io)
get the user data from an io object
#define ARENA_MALLOC(size, name, parent, arena)
allocate 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
io_read_t fn_read
read callback may be NULL on non-readable objects
size_t size
the size of the io objects private data
io_write_t fn_write
write callback may be NULL on non-writable objects
char data[]
user data region
arena_t * arena
the arena this object was allocated from
const char * name
the name of this object
os_error_t error
the last error set on this object
const io_callbacks_t * cb
callback struct
os_access_t flags
the access flags for this object