SharedMeatAxe
1.0
|
These functions are used to work with dynamically allocated strings.
A dynamic string contains a normal «char*» pointing to a NUL terminated text. Note however, that dynamic strings use their own memory management which cannot be mixed with the standard C library memory functions. Unused strings must be freed with StrFree(), and you must never use free() or realloc() on a dynamic string.
Data Structures | |
struct | String |
A dynamic string. More... | |
Functions | |
String | StrAlloc (size_t initial_capacity) |
Create a string. More... | |
void | StrFree (String *s) |
Free a string. More... | |
void | StrAppend (String *s, const char *text) |
Appends text to the end of a string. More... | |
void | StrAppendF (String *s, const char *fmt,...) |
snprintf() replacement. More... | |
void | StrPrintF (String *s, const char *fmt,...) |
snprintf() replacement. More... | |
void | StrVAppendF (String *s, const char *fmt, va_list args) |
vsnprintf() replacement. More... | |
void | StrVPrintF (String *s, const char *fmt, va_list args) |
vsnprintf() replacement. More... | |
String StrAlloc | ( | size_t | initial_capacity | ) |
Create a string.
This function creates an empty string.
initial_capacity | Number of bytes to reserve on allocation. |
void StrAppend | ( | String * | s, |
const char * | text | ||
) |
Appends text to the end of a string.
s | The string to be modified. |
text | Text to append. |
void StrAppendF | ( | String * | s, |
const char * | fmt, | ||
... | |||
) |
snprintf() replacement.
Works like StrVAppendF() but expects a variable argument list.
void StrFree | ( | String * | s | ) |
void StrPrintF | ( | String * | s, |
const char * | fmt, | ||
... | |||
) |
snprintf() replacement.
Works like StrVPrintF() but expects a variable argument list.
void StrVAppendF | ( | String * | s, |
const char * | fmt, | ||
va_list | args | ||
) |
vsnprintf() replacement.
Formats a string with vsnprintf() and appends the resulting text to «s».
s | The string to be modified. |
fmt | Format |
args | Arguments for the % placeholders in fmt. |
void StrVPrintF | ( | String * | s, |
const char * | fmt, | ||
va_list | args | ||
) |
vsnprintf() replacement.
Works like StrVAppendF() but overwrites the string with the formatted text.
s | The string to be modified. |
fmt | Format |
args | Arguments for the % placeholders in fmt. |