Dynamic strings were introduced to satisfy needs of presence modules when building presence documents. More...
|
Dynamic string uses a list of buffers holding data. Buffers are allocated when needed - when there is not enough space in the last buffer. The whole result can be copied into one destination buffer with dstr_get_data, dstr_get_str or dstr_get_str_pkg function.
| #define dstr_error | ( | dstr | ) | (dstr)->error |
| #define dstr_get_data_length | ( | dstr | ) | (dstr)->len |
Definition at line 135 of file dstring.h.
Referenced by dstr_get_str(), and dstr_get_str_pkg().
| typedef struct _dstr_buff_t dstr_buff_t |
| typedef struct _dstring_t dstring_t |
It is used for muliple appends of any strings.
| int dstr_append | ( | dstring_t * | dstr, | |
| const char * | s, | |||
| int | len | |||
| ) |
| 0 | if successful | |
| negative | on error |
Definition at line 57 of file dstring.c.
References _dstring_t::error, _dstring_t::len, _dstr_buff_t::len, and _dstr_buff_t::used.
Referenced by dstr_append_str(), and dstr_append_zt().

| int dstr_append_str | ( | dstring_t * | dstr, | |
| const str_t * | s | |||
| ) |
| 0 | if successful | |
| negative | on error |
Definition at line 93 of file dstring.c.
References dstr_append(), and _dstring_t::len.

| int dstr_append_zt | ( | dstring_t * | dstr, | |
| const char * | s | |||
| ) |
| 0 | if successful | |
| negative | on error |
Definition at line 86 of file dstring.c.
References dstr_append().

| int dstr_destroy | ( | dstring_t * | dstr | ) |
It frees all allocated buffers.
Definition at line 189 of file dstring.c.
References cds_free_pkg, _dstring_t::first, _dstring_t::last, and _dstr_buff_t::next.
| int dstr_get_data | ( | dstring_t * | dstr, | |
| char * | dst | |||
| ) |
It does NOT allocate space for them - it expects that the buffer is already allocated.
| 0 | if successful | |
| negative | on error |
Definition at line 106 of file dstring.c.
References _dstring_t::error, _dstring_t::first, _dstr_buff_t::next, and _dstr_buff_t::used.
Referenced by dstr_get_str(), and dstr_get_str_pkg().

| int dstr_get_str | ( | dstring_t * | dstr, | |
| str_t * | dst | |||
| ) |
It allocates space for them with cds_malloc (SER's shared memory).
| 0 | if successful | |
| negative | on error |
Definition at line 122 of file dstring.c.
References cds_malloc, dstr_get_data(), dstr_get_data_length, and _dstring_t::error.

| int dstr_get_str_pkg | ( | dstring_t * | dstr, | |
| str_t * | dst | |||
| ) |
It allocates space for them with cds_malloc_pkg (SER's package memory).
| 0 | if successful | |
| negative | on error |
Definition at line 150 of file dstring.c.
References cds_malloc_pkg, dstr_get_data(), dstr_get_data_length, and _dstring_t::error.

| int dstr_init | ( | dstring_t * | dstr, | |
| int | buff_size | |||
| ) |
| dstr | dynamic string to be initialized | |
| buff_size | size of buffer used with this dynamic string |
| 0 | if successful | |
| negative | on error |
Definition at line 178 of file dstring.c.
References _dstring_t::buff_size, _dstring_t::error, _dstring_t::first, _dstring_t::last, and _dstring_t::len.
1.7.1