Small, Fast S-Expression Library
|
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | __cstring |
Typedefs | |
typedef struct __cstring | CSTRING |
Functions | |
void | sgrowsize (size_t s) |
CSTRING * | snew (size_t s) |
CSTRING * | sadd (CSTRING *s, char *a) |
CSTRING * | saddch (CSTRING *s, char a) |
CSTRING * | strim (CSTRING *s) |
char * | toCharPtr (CSTRING *s) |
void | sempty (CSTRING *s) |
void | sdestroy (CSTRING *s) |
cstring.h : c string library to make Ron happy. Wrapper around plain C strings that handles automatically growing the string as data is concattenated to the end. (note: this is an improved version of cstring from supermon. Migrate it into that library eventually... )
-matt sottile Structure wrapping the character pointer and size counters (allocated vs. actual used).
Concatenate the second argument to the CSTRING passed in the first. The second argument must be a pointer to a null terminated string. A NULL return value indicates that something went wrong and that sexp_errno should be checked for the cause. The contents of s are left alone. As such, the caller should check the pointer returned before overwriting the value of s, as this may result in a memory leak if an error condition occurs.
Append a character to the end of the CSTRING. A NULL return value indicates that something went wrong and that sexp_errno should be checked for the cause. The contents of s are left alone. As such, the caller should check the pointer returned before overwriting the value of s, as this may result in a memory leak if an error condition occurs.
void sdestroy | ( | CSTRING * | s | ) |
Destroy the CSTRING struct and the data it points at.
void sempty | ( | CSTRING * | s | ) |
Set the current length to zero, effectively dumping the string without deallocating it so we can use it later without reallocating any memory.
void sgrowsize | ( | size_t | s | ) |
Set the growth size. Values less than one are ignored.
CSTRING* snew | ( | size_t | s | ) |
Allocate a new CSTRING of the given size. A NULL return value indicates that something went wrong and that sexp_errno should be checked for the cause.
Trim the allocated memory to precisely the string length plus one char to hold the null terminator A NULL return value indicates that something went wrong and that sexp_errno should be checked for the cause. The contents of s are left alone. As such, the caller should check the pointer returned before overwriting the value of s, as this may result in a memory leak if an error condition occurs.
char* toCharPtr | ( | CSTRING * | s | ) |
Return the base pointer of the CSTRING. NULL either means the base pointer was null, or the CSTRING itself was NULL.