cstring.h File Reference

#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  __cstring

Typedefs

typedef __cstring CSTRING

Functions

void sgrowsize (size_t s)
CSTRINGsnew (size_t s)
CSTRINGsadd (CSTRING *s, char *a)
CSTRINGsaddch (CSTRING *s, char a)
CSTRINGstrim (CSTRING *s)
char * toCharPtr (CSTRING *s)
void sempty (CSTRING *s)
void sdestroy (CSTRING *s)


Typedef Documentation

typedef struct __cstring CSTRING
 

Structure wrapping the character pointer and size counters (allocated vs. actual used).


Function Documentation

CSTRING* sadd CSTRING s,
char *  a
 

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.

CSTRING* saddch CSTRING s,
char  a
 

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.

CSTRING* strim CSTRING s  ) 
 

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.


Generated on Thu Oct 25 01:19:37 2007 for Small, Fast S-Expression Library by  doxygen 1.4.6