For saving memory on the storage of (largely) constant strings that occur in many instances during runtime: module names, gate names, property names, keys and values, etc. More...
#include <cstringpool.h>
Public Member Functions | |
const char * | get (const char *s) |
const char * | peek (const char *s) const |
void | release (const char *s) |
void | dump () const |
For saving memory on the storage of (largely) constant strings that occur in many instances during runtime: module names, gate names, property names, keys and values, etc.
These strings can be stored in a cStringPool as one shared instance. Strings in the cStringPool are reference counted. (See Flyweight GoF pattern.)
const char* cStringPool::get | ( | const char * | s | ) |
const char* cStringPool::peek | ( | const char * | s | ) | const |
Returns pointer to the pooled copy of the given string, or NULL.
Reference count is not incremented. Passing NULL is OK.
void cStringPool::release | ( | const char * | s | ) |
The parameter must a pointer returned by get().
It decrements the reference count and frees the pooled string if it reaches zero. Passing NULL is OK.