]> git.lyx.org Git - lyx.git/blob - src/support/StrPool.C
ws cleanup
[lyx.git] / src / support / StrPool.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2000-2001 Jean-Marc Lasgouttes
7  *
8  * ======================================================*/
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15 #include "StrPool.h"
16
17
18 StrPool::~StrPool()
19 {
20         for (Pool::const_iterator cit = pool_.begin();
21              cit != pool_.end() ; ++cit) {
22                 delete[] (*cit);
23         }
24 }
25
26 /* One interesting thing here would be to store the strings in a map,
27    so that one string is only stored once. This would make things a
28    bit slower, but memory requirements would be lower in the long run.
29    I expect that it would be fast enough anyway. (Lgb)
30 */
31 char const * StrPool::add(string const & str)
32 {
33         string::size_type s = str.length();
34         char * buf = new char [s + 1];
35         str.copy(buf, s);
36         buf[s] = '\0';
37         pool_.push_back(buf);
38         return buf;
39 }
40
41 //StrPool strPool;