Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions

An arena is an object that does allocation on user's behalf and can deallocate all at once. More...

Typedefs

typedef struct sol_arena sol_arena
 Sol Arena type. More...
 

Functions

void sol_arena_del (struct sol_arena *arena)
 Delete the Arena. More...
 
struct sol_arenasol_arena_new (void)
 Creates an Arena. More...
 
int sol_arena_slice_dup (struct sol_arena *arena, struct sol_str_slice *dst, struct sol_str_slice src)
 Store a copy of a given string slice in the arena. More...
 
int sol_arena_slice_dup_str (struct sol_arena *arena, struct sol_str_slice *dst, const char *src)
 Store a copy of a given string in the arena. More...
 
int sol_arena_slice_dup_str_n (struct sol_arena *arena, struct sol_str_slice *dst, const char *src, size_t n)
 Store a copy of at most n characters of a given string in the arena. More...
 
int sol_arena_slice_sprintf (struct sol_arena *arena, struct sol_str_slice *dst, const char *fmt,...) SOL_ATTR_PRINTF(3
 Store the output of 'sprintf()' in the arena. More...
 
char * sol_arena_str_dup_n (struct sol_arena *arena, const char *str, size_t n)
 Store a copy of at most n characters of a given string in the arena. More...
 
int char * sol_arena_strdup (struct sol_arena *arena, const char *str)
 Store a copy of a given string in the arena. More...
 
char * sol_arena_strdup_slice (struct sol_arena *arena, const struct sol_str_slice slice)
 Store a copy of a given string slice in the arena. More...
 

Detailed Description

An arena is an object that does allocation on user's behalf and can deallocate all at once.

See Also
String slice

Typedef Documentation

Sol Arena type.

See also sol_buffer if you just need a single re-sizable buffer.

Function Documentation

void sol_arena_del ( struct sol_arena arena)

Delete the Arena.

Delete the arena and all it's contents. Frees all the memory previously allocated by the arena.

Parameters
arenaArena to be deleted
struct sol_arena* sol_arena_new ( void  )

Creates an Arena.

Returns
The new arena, NULL in case of error
int sol_arena_slice_dup ( struct sol_arena arena,
struct sol_str_slice dst,
struct sol_str_slice  src 
)

Store a copy of a given string slice in the arena.

Also, outputs the recently stored string src in dst.

Parameters
arenaThe arena
dstString slice of the recently added string slice
srcString slice to copy and store
Returns
0 on success, error code (always negative) otherwise
int sol_arena_slice_dup_str ( struct sol_arena arena,
struct sol_str_slice dst,
const char *  src 
)

Store a copy of a given string in the arena.

Also, outputs a slice to the stored string in dst.

Parameters
arenaThe arena
dstString slice of the recently added string
srcString to copy and store
Returns
0 on success, error code (always negative) otherwise
int sol_arena_slice_dup_str_n ( struct sol_arena arena,
struct sol_str_slice dst,
const char *  src,
size_t  n 
)

Store a copy of at most n characters of a given string in the arena.

Also, outputs a slice to the stored string in dst.

Parameters
arenaThe arena
dstString slice of the recently added string
srcString to copy and store
nMaximum number of characters to copy
Returns
0 on success, error code (always negative) otherwise
int sol_arena_slice_sprintf ( struct sol_arena arena,
struct sol_str_slice dst,
const char *  fmt,
  ... 
)

Store the output of 'sprintf()' in the arena.

Also, outputs a slice to the stored string in dst.

Parameters
arenaThe arena
dstString slice of the recently added string
fmtA standard 'printf()' format string
...The arguments for 'sprintf()'
Returns
0 on success, error code (always negative) otherwise
char* sol_arena_str_dup_n ( struct sol_arena arena,
const char *  str,
size_t  n 
)

Store a copy of at most n characters of a given string in the arena.

Parameters
arenaThe arena
strString to copy and store
nMaximum number of characters to copy
Returns
The stored string
int char* sol_arena_strdup ( struct sol_arena arena,
const char *  str 
)

Store a copy of a given string in the arena.

Parameters
arenaThe arena
strString to copy and store
Returns
The stored string
char* sol_arena_strdup_slice ( struct sol_arena arena,
const struct sol_str_slice  slice 
)

Store a copy of a given string slice in the arena.

Parameters
arenaThe arena
sliceString slice to copy and store
Returns
The stored string