//===- StringEntry.cpp ----------------------------------------------------===// // // The MCLinker Project // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "mcld/ADT/StringEntry.h" namespace mcld { //===----------------------------------------------------------------------===// // StringEntry //===----------------------------------------------------------------------===// StringEntry::StringEntry() { } StringEntry::StringEntry(const StringEntry::key_type& pKey) { } StringEntry::StringEntry( const StringEntry& pCopy) { assert("Copy constructor of StringEntry should not be called!"); } StringEntry::~StringEntry() { if (!m_Value.empty()) free(const_cast(m_Value.data())); } void StringEntry::setValue(llvm::StringRef pVal) { char* data = reinterpret_cast(malloc(pVal.size() + 1)); ::memcpy(data, pVal.data(), pVal.size()); m_Value = llvm::StringRef(data, pVal.size()); } void StringEntry::setValue(const char* pVal) { size_t length = strlen(pVal); char* data = reinterpret_cast(malloc(length + 1)); ::memcpy(data, pVal, length); m_Value = llvm::StringRef(data, length); } } // namespace mcld