|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU Lesser General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Lesser General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #include <string.h> |
|
20 |
|
21 #include "elfstringtable.h" |
|
22 |
|
23 void ElfStringTable::GetFileFragmentData(FileFragmentData & aFileFragmentData ){ |
|
24 size_t nbytes = Size(); |
|
25 iData = new char[nbytes]; |
|
26 memset(iData, 0, nbytes); |
|
27 if (iStrings.size() > 0) { |
|
28 StringList::iterator aString = iStrings.begin(); |
|
29 StringList::iterator end = iStrings.end(); |
|
30 while (aString != end) { |
|
31 memcpy(iData + aString->iOffset, aString->iName.data(), aString->iName.size()); |
|
32 aString++; |
|
33 } |
|
34 } |
|
35 SetFileFragmentData(aFileFragmentData, nbytes, reinterpret_cast<char *>(iData)); |
|
36 } |
|
37 |
|
38 size_t ElfStringTable::Size() { |
|
39 return iSize; |
|
40 } |
|
41 |
|
42 void ElfStringTable::DeleteFileFragmentData(){ |
|
43 if (iData) { |
|
44 char * d = iData; |
|
45 iData = NULL; |
|
46 delete [] d; |
|
47 } |
|
48 } |
|
49 |
|
50 size_t ElfStringTable::AddString(String aString){ |
|
51 size_t offset = iSize; |
|
52 StringTableEntry sn(aString, offset); |
|
53 iStrings.push_back(sn); |
|
54 size_t ss = aString.size(); |
|
55 iSize += (ss + 1); |
|
56 return offset; |
|
57 } |