squareball/sb-string.h File Reference
String object that grows automatically, as required by the content added to it.
More...
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Detailed Description
String object that grows automatically, as required by the content added to it.
Function Documentation
Function that appends a nul-terminated suffix
to the string object.
- Parameters:
-
| str | The string object. |
| suffix | The nul-terminated suffix to append to the string object. |
- Returns:
- The modified string object.
- Examples:
- hello_string.c.
Function that appends a character to the string object.
- Parameters:
-
| str | The string object. |
| c | The character to append to the string object. |
- Returns:
- The modified string object.
- Examples:
- hello_string.c.
Function that appends a nul-terminated suffix
to string object, escaping the suffix before appending.
- Parameters:
-
| str | The string object. |
| suffix | The nul-terminated suffix to append to the string object. |
- Returns:
- The modified string object.
Function that appends len
bytes from suffix
to the string object.
- Parameters:
-
| str | The string object. |
| suffix | The suffix to append to the string object. |
| len | The number of bytes from suffix to append to the string object. |
- Returns:
- The modified string object.
- Examples:
- hello_string.c.
Function that appends to an string object with a printf(3)-like interface.
- Parameters:
-
| str | The string object. |
| format | A printf(3) format. |
| ... | One or more printf(3)-like parameters. |
- Returns:
- The modified string object.
- Examples:
- hello_string.c.
Function that duplicates a string object.
- Parameters:
-
- Returns:
- A newly-allocated copy of
str
.
char* sb_string_free |
( |
sb_string_t * |
str, |
|
|
bool |
free_str | |
|
) |
| | |
Function that frees memory allocated for a string object. If free_str
is false
, it will only free the memory allocated for the object, and return the string stored on it.
- Parameters:
-
| str | The string object. |
| free_str | Boolean that indicates if the memory allocated to internal string should be free'd. |
- Returns:
- Internal string, passing ownership of it to the caller of the function, if
free_str
is false
, or NULL.
- Examples:
- hello_string.c.
Function that creates an empty string object.
- Returns:
- New string object.
- Examples:
- hello_string.c.