|
Atrinik Server 2.5
|
Go to the source code of this file.
Functions | |
| static void | stringbuffer_ensure (StringBuffer *sb, size_t len) |
| StringBuffer * | stringbuffer_new () |
| char * | stringbuffer_finish (StringBuffer *sb) |
| const char * | stringbuffer_finish_shared (StringBuffer *sb) |
| void | stringbuffer_append_string (StringBuffer *sb, const char *str) |
| void | stringbuffer_append_printf (StringBuffer *sb, const char *format,...) |
| void | stringbuffer_append_stringbuffer (StringBuffer *sb, const StringBuffer *sb2) |
| size_t | stringbuffer_length (StringBuffer *sb) |
Implements a general string buffer: it builds a string by concatenating. It allocates enough memory to hold the whole string; there is no upper limit for the total string length.
Usage is:
StringBuffer *sb = stringbuffer_new(); stringbuffer_append_string(sb, "abc"); stringbuffer_append_string(sb, "def"); ... more calls to stringbuffer_append_xxx() char *str = stringbuffer_finish(sb); ... use str free(str);
No function ever fails. In case not enough memory is available, the program exits.
Definition in file stringbuffer.c.
| void stringbuffer_append_printf | ( | StringBuffer * | sb, |
| const char * | format, | ||
| ... | |||
| ) |
Append a formatted string to a string buffer instance.
| sb | The string buffer to modify. |
| format | The format string to append. |
Definition at line 119 of file stringbuffer.c.
| void stringbuffer_append_string | ( | StringBuffer * | sb, |
| const char * | str | ||
| ) |
Append a string to a string buffer instance.
| sb | The string buffer to modify. |
| str | The string to append. |
Definition at line 106 of file stringbuffer.c.
| void stringbuffer_append_stringbuffer | ( | StringBuffer * | sb, |
| const StringBuffer * | sb2 | ||
| ) |
Append the contents of a string buffer instance to another string buffer instance.
| sb | The string buffer to modify. |
| sb2 | The string buffer to append; it must be different from sb. |
Definition at line 158 of file stringbuffer.c.
| static void stringbuffer_ensure | ( | StringBuffer * | sb, |
| size_t | len | ||
| ) | [static] |
Make sure that at least len bytes are available in the passed string buffer.
| sb | The string buffer to modify. |
| len | The number of bytes to allocate. |
Definition at line 170 of file stringbuffer.c.
| char* stringbuffer_finish | ( | StringBuffer * | sb | ) |
Deallocate the string buffer instance and return the string.
The passed string buffer must not be accessed afterwards.
| sb | The string buffer to deallocate. |
Definition at line 75 of file stringbuffer.c.
| const char* stringbuffer_finish_shared | ( | StringBuffer * | sb | ) |
Deallocate the string buffer instance and return the string as a shared string.
The passed string buffer must not be accessed afterwards.
| sb | The string buffer to deallocate. |
Definition at line 93 of file stringbuffer.c.
| size_t stringbuffer_length | ( | StringBuffer * | sb | ) |
Return the current length of the buffer.
| sb | The string buffer to check. |
Definition at line 196 of file stringbuffer.c.
| StringBuffer* stringbuffer_new | ( | ) |
Create a new string buffer.
Definition at line 54 of file stringbuffer.c.
1.7.4