//===- StringEntry.tcc ----------------------------------------------------===// // // The MCLinker Project // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // StringEntry template StringEntry::StringEntry() : m_KeyLen(0) { } template StringEntry::StringEntry(const StringEntry::key_type& pKey) : m_KeyLen(pKey.size()) { } template StringEntry::StringEntry(const StringEntry& pCopy) : m_KeyLen(pCopy.m_KeyLen), m_Value(pCopy.m_Value) { assert("Copy constructor of StringEntry should not be called!"); } template StringEntry::~StringEntry() { } //===----------------------------------------------------------------------===// // StringEntryFactory template StringEntryFactory::StringEntryFactory() { } template StringEntryFactory::~StringEntryFactory() { } template StringEntry* StringEntryFactory::produce( const typename StringEntryFactory::key_type& pKey) { StringEntry* result = static_cast*>( malloc(sizeof(StringEntry) + pKey.size() + 1)); if (result == NULL) return NULL; size_t len = pKey.size(); new (result) StringEntry(); std::memcpy(result->m_Key, pKey.data(), len); result->m_Key[len] = '\0'; result->m_KeyLen = len; return result; } template void StringEntryFactory::destroy(StringEntry* pEntry) { if (pEntry != NULL) { pEntry->~StringEntry(); free(pEntry); } }