uLib
User mode C/C++ extended API library for Win32 programmers.
|
#include <uLib/StrFunc.h>
StringCache ia a pre-allocated string cache class.
Memory is chunk-wise allocated on demand by DupStr(), and freed by the d'tor.
StringCache is intended for memory-efficient string lists, f.ex. keyword tables,
and therefore doesn't support Unicode strings.
The Storage buffer is maintained such that it can be used for multi-string operations.
You can use MultiSzCount() if you need a count of strings in Storage.
Public Data | |
char * | Storage |
Public Functions | |
StringCache (UINT InitSize=4096, UINT ChunkSize=4096) | |
~StringCache () | |
char * | DupStr (char *Str) |
void | Reset () |
void | Free () |
int | StorageSize () |
int | StorageUsed () |
Protected Member Functions | |
bool | GrowStorage () |
Protected Attributes | |
UINT | StgSize |
UINT | StgUsed |
UINT | StgChunk |
StringCache::StringCache | ( | UINT | InitSize = 4096 , |
UINT | ChunkSize = 4096 |
||
) |
Use ChunkSize strategically to minimize reallocation and slack.
InitSize | Size of initial memory block to allocate (rounded up to nearest ChunkSize). |
ChunkSize | Size of memory block to add per (re)allocation. |
Definition at line 1558 of file StrFunc.cpp.
StringCache::~StringCache | ( | ) |
The d'tor frees allocated Storage memory.
Definition at line 1572 of file StrFunc.cpp.
char * StringCache::DupStr | ( | char * | Str | ) |
Copy Str into next available Storage.
Definition at line 1616 of file StrFunc.cpp.
void StringCache::Reset | ( | ) |
Un-use all memory.. No deallocation.
Definition at line 1577 of file StrFunc.cpp.
void StringCache::Free | ( | ) |
Deallocate all memory.
Definition at line 1582 of file StrFunc.cpp.
|
protected |
Definition at line 1588 of file StrFunc.cpp.
char* StringCache::Storage |