Get a C string from a persistent string¶
ss_string_get
is a function defined in ssstring.c.
Synopsis:
-
char *
ss_string_get
(const ss_string_t *str, size_t bufsize, char *buf)¶
Formal Arguments:
bufsize
: Size ofbuf
(only referenced ifbuf
is non-null).buf
: Optional buffer in which to store the C string. This buffer is assumed to be an array of at leastbufsize
characters.
Description: Given information about a persistent string, return a pointer to a C string, i.e., an array of NUL
-terminated
characters. If the caller supplies a buffer then the string will be copied into that buffer and NUL
terminated, otherwise this function mallocs a new buffer to hold the result.
Return Value: On success, returns buf
if non-null or else allocates a result buffer. On failure returns the null pointer.
It is a failure to supply a bufsize
which is not large enough to hold the entire string value with its NUL
terminator. The caller is responsible for freeing any return value allocated by this function.
Parallel Notes: Independent
Issues: SSlib stores strings with a byte count, so if the string was stored without a terminating NUL
character then
it will also be returned as such.
See Also:
- Strings: Introduction for current chapter