2000-07-24 13:53:19 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 2000-2001 Jean-Marc Lasgouttes
|
2000-07-24 13:53:19 +00:00
|
|
|
*
|
|
|
|
* ======================================================*/
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "StrPool.h"
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
StrPool::~StrPool()
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
for (Pool::const_iterator cit = pool_.begin();
|
2000-07-24 13:53:19 +00:00
|
|
|
cit != pool_.end() ; ++cit) {
|
|
|
|
delete[] (*cit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
/* One interesting thing here would be to store the strings in a map,
|
|
|
|
so that one string is only stored once. This would make things a
|
|
|
|
bit slower, but memory requirements would be lower in the long run.
|
|
|
|
I expect that it would be fast enough anyway. (Lgb)
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
char const * StrPool::add(string const & str)
|
|
|
|
{
|
2000-10-18 14:07:29 +00:00
|
|
|
string::size_type s = str.length();
|
2000-07-24 13:53:19 +00:00
|
|
|
char * buf = new char [s + 1];
|
|
|
|
str.copy(buf, s);
|
|
|
|
buf[s] = '\0';
|
|
|
|
pool_.push_back(buf);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
//StrPool strPool;
|
|
|
|
|