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