/* * file: ssstore.cpp * * Created on: Oct 3, 2009 * Author: mike */ #include "tools.hpp" #include "ssstore.hpp" //---------------------------------------------------------------------------- // Constructs new const null-terminated string from first len characters of s, // places it in the StringStore repository, and returns pointer to it. // Repository owns the new string and is responsible for its eventual deletion. const char* StringStore::put( const char* s, int len ) { len++; // number of characters including '\0'. if ( len > remain ) fatal("Sorry, string too long for string store"); cstring where = &letters[next]; next += len; remain -= len; strncpy( where, s, len-1 ); where[len-1] = '\0'; return where; }