//============================================================================ // StringStore data structure -- implementation. // A. Fischer, May 29, 2000 file: sstore.cpp // Modified by M. Fischer, October 8, 2009 //=========================================================================== #include "sstore.hpp" //=========================================================================== StringStore::~StringStore() { Pool* p; while (current != NULL) { p = current; current = p->prev; delete p; } } //---------------------------------------------------------------------------- const_cstring StringStore::put( const_cstring s, int len ) { len++; // number of characters including '\0'. if ( len > remain ) { // no room to store s in current Pool. if ( len > MAXLETS ) fatal("Sorry, string too long for string store"); current = new Pool( current ); next = 0; remain = MAXLETS; } cstring where = ¤t->letters[next]; next += len; remain -= len; strcpy( where, s ); return where; }