src/hbtools/hbbincssmaker/hbcssconverterutils.cpp
changeset 7 923ff622b8b9
parent 5 627c4a0fd0e7
child 21 4633027730f5
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <QMap>
    26 #include <QMap>
       
    27 #include <QHash>
       
    28 #include "hbstring_p.h"
    27 #include "hbcssconverterutils_p.h"
    29 #include "hbcssconverterutils_p.h"
    28 #include "hbsharedmemorymanager_p.h"
    30 #include "hbsharedmemorymanager_p.h"
    29 #include "hbsharedmemoryallocators_p.h"
    31 #include "hbsharedmemoryallocators_p.h"
       
    32 
       
    33 static QHash<QString, HbString> strMap;
    30 
    34 
    31 // Global list that stores pointers to the member variables where shared container instances
    35 // Global list that stores pointers to the member variables where shared container instances
    32 // store offsets returned my memory allocator.
    36 // store offsets returned my memory allocator.
    33 // CSS converter utilizes it to automatically adjust the offsets if allocated cells are moved.
    37 // CSS converter utilizes it to automatically adjust the offsets if allocated cells are moved.
    34 
    38 
   137 */
   141 */
   138 int HbCssConverterUtils::defragmentChunk()
   142 int HbCssConverterUtils::defragmentChunk()
   139 {
   143 {
   140     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
   144     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
   141     HbSharedMemoryManager *shared = static_cast<HbSharedMemoryManager*>(manager);
   145     HbSharedMemoryManager *shared = static_cast<HbSharedMemoryManager*>(manager);
       
   146     strMap.clear();
   142 
   147 
   143     // Register shared cache pointer in chunk header
   148     // Register shared cache pointer in chunk header
   144     //as shared cache may also be moved in defragmentation
   149     //as shared cache may also be moved in defragmentation
   145     HbSharedChunkHeader *chunkHeader = static_cast<HbSharedChunkHeader*>(shared->base());
   150     HbSharedChunkHeader *chunkHeader = static_cast<HbSharedChunkHeader*>(shared->base());
   146     registerOffsetHolder(reinterpret_cast<int *>(&chunkHeader->sharedCacheOffset));
   151     registerOffsetHolder(reinterpret_cast<int *>(&chunkHeader->sharedCacheOffset));
   205     ::free(buffer);
   210     ::free(buffer);
   206 
   211 
   207     // Return the next free address in the chunk
   212     // Return the next free address in the chunk
   208     return cssBinaryOffset + newCurrentOffset;
   213     return cssBinaryOffset + newCurrentOffset;
   209 }
   214 }
       
   215 
       
   216 void HbCssConverterUtils::addSharedStringData(const QString &str, const HbString &hbstr)
       
   217 {
       
   218     if (!strMap.contains(str)) {
       
   219         strMap.insert(str, hbstr);
       
   220     }
       
   221 }
       
   222 
       
   223 HbString* HbCssConverterUtils::sharedStringData(const QString &str)
       
   224 {
       
   225     HbString *ret = 0;
       
   226     QHash<QString, HbString>::iterator i = strMap.find(str);
       
   227     if (i != strMap.end()) {
       
   228         ret = &i.value();
       
   229     }
       
   230     return ret;
       
   231 }
       
   232