1//===- StringEntry.cpp -----------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#include <mcld/ADT/StringEntry.h> 10 11using namespace mcld; 12 13//===----------------------------------------------------------------------===// 14// StringEntry<llvm::StringRef> 15//===----------------------------------------------------------------------===// 16StringEntry<llvm::StringRef>::StringEntry() 17{ 18} 19 20StringEntry<llvm::StringRef>::StringEntry(const StringEntry::key_type& pKey) 21{ 22} 23 24StringEntry<llvm::StringRef>::StringEntry(const StringEntry<llvm::StringRef>& pCopy) 25{ 26 assert("Copy constructor of StringEntry should not be called!"); 27} 28 29StringEntry<llvm::StringRef>::~StringEntry() 30{ 31 if (!m_Value.empty()) 32 free(const_cast<char*>(m_Value.data())); 33} 34 35void StringEntry<llvm::StringRef>::setValue(llvm::StringRef& pVal) 36{ 37 char* data = (char*)malloc(pVal.size()+1); 38 strcpy(data, pVal.data()); 39 m_Value = llvm::StringRef(data, pVal.size()); 40} 41 42void StringEntry<llvm::StringRef>::setValue(const char* pVal) 43{ 44 size_t length = strlen(pVal); 45 char* data = (char*)malloc(length+1); 46 strcpy(data, pVal); 47 m_Value = llvm::StringRef(data, length); 48} 49 50