Functions

Create/Destroy StrBufs
[Stringbuffer, A class for manipulating strings with dynamic buffers]

Functions

void ReAdjustEmptyBuf (StrBuf *Buf, long ThreshHold, long NewSize)
 shrink / increase an _EMPTY_ buffer to NewSize. Buffercontent is thoroughly ignored and flushed.
long StrBufShrinkToFit (StrBuf *Buf, int Force)
 shrink long term buffers to their real size so they don't waste memory
StrBufNewStrBuf (void)
 Allocate a new buffer with default buffer size.
StrBufNewStrBufDup (const StrBuf *CopyMe)
 Copy Constructor; returns a duplicate of CopyMe.
StrBufNewStrBufPlain (const char *ptr, int nChars)
 create a new Buffer using an existing c-string this function should also be used if you want to pre-suggest the buffer size to allocate in conjunction with ptr == NULL
int StrBufPlain (StrBuf *Buf, const char *ptr, int nChars)
 Set an existing buffer from a c-string.
StrBuf_NewConstStrBuf (const char *StringConstant, size_t SizeOfStrConstant)
 use strbuf as wrapper for a string constant for easy handling
int FlushStrBuf (StrBuf *buf)
 flush the content of a Buf; keep its struct
int FLUSHStrBuf (StrBuf *buf)
 wipe the content of a Buf thoroughly (overwrite it -> expensive); keep its struct
void FreeStrBuf (StrBuf **FreeMe)
 Release a Buffer Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results.
char * SmashStrBuf (StrBuf **SmashMe)
 flatten a Buffer to the Char * we return Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results The Callee then owns the buffer and is responsible for freeing it.
void HFreeStrBuf (void *VFreeMe)
 Release the buffer If you want put your StrBuf into a Hash, use this as Destructor.

Function Documentation

StrBuf* _NewConstStrBuf ( const char *  StringConstant,
size_t  SizeOfStrConstant 
)

use strbuf as wrapper for a string constant for easy handling

Parameters:
StringConstant a string to wrap
SizeOfStrConstant should be sizeof(StringConstant)-1
int FlushStrBuf ( StrBuf buf  ) 

flush the content of a Buf; keep its struct

Parameters:
buf Buffer to flush
int FLUSHStrBuf ( StrBuf buf  ) 

wipe the content of a Buf thoroughly (overwrite it -> expensive); keep its struct

Parameters:
buf Buffer to wipe
void FreeStrBuf ( StrBuf **  FreeMe  ) 

Release a Buffer Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results.

Parameters:
FreeMe Pointer Pointer to the buffer to free
void HFreeStrBuf ( void *  VFreeMe  ) 

Release the buffer If you want put your StrBuf into a Hash, use this as Destructor.

Parameters:
VFreeMe untyped pointer to a StrBuf. be shure to do the right thing [TM]
StrBuf* NewStrBuf ( void   ) 

Allocate a new buffer with default buffer size.

Returns:
the new stringbuffer
StrBuf* NewStrBufDup ( const StrBuf CopyMe  ) 

Copy Constructor; returns a duplicate of CopyMe.

Parameters:
CopyMe Buffer to faxmilate
Returns:
the new stringbuffer
StrBuf* NewStrBufPlain ( const char *  ptr,
int  nChars 
)

create a new Buffer using an existing c-string this function should also be used if you want to pre-suggest the buffer size to allocate in conjunction with ptr == NULL

Parameters:
ptr the c-string to copy; may be NULL to create a blank instance
nChars How many chars should we copy; -1 if we should measure the length ourselves
Returns:
the new stringbuffer
void ReAdjustEmptyBuf ( StrBuf Buf,
long  ThreshHold,
long  NewSize 
)

shrink / increase an _EMPTY_ buffer to NewSize. Buffercontent is thoroughly ignored and flushed.

Parameters:
Buf Buffer to shrink (has to be empty)
ThreshHold if the buffer is bigger then this, its readjusted
NewSize if we Shrink it, how big are we going to be afterwards?
char* SmashStrBuf ( StrBuf **  SmashMe  ) 

flatten a Buffer to the Char * we return Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results The Callee then owns the buffer and is responsible for freeing it.

Parameters:
SmashMe Pointer Pointer to the buffer to release Buf from and free
Returns:
the pointer of the buffer; Callee owns the memory thereafter.
int StrBufPlain ( StrBuf Buf,
const char *  ptr,
int  nChars 
)

Set an existing buffer from a c-string.

Parameters:
Buf buffer to load
ptr c-string to put into
nChars set to -1 if we should work 0-terminated
Returns:
the new length of the string
long StrBufShrinkToFit ( StrBuf Buf,
int  Force 
)

shrink long term buffers to their real size so they don't waste memory

Parameters:
Buf buffer to shrink
Force if not set, will just executed if the buffer is much to big; set for lifetime strings
Returns:
physical size of the buffer
 All Classes Variables