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> 15StringEntry<llvm::StringRef>::StringEntry() 16{ 17} 18 19StringEntry<llvm::StringRef>::StringEntry(const StringEntry::key_type& pKey) 20{ 21} 22 23StringEntry<llvm::StringRef>::StringEntry(const StringEntry<llvm::StringRef>& pCopy) 24{ 25 assert("Copy constructor of StringEntry should not be called!"); 26} 27 28StringEntry<llvm::StringRef>::~StringEntry() 29{ 30 if (!m_Value.empty()) 31 free(const_cast<char*>(m_Value.data())); 32} 33 34void StringEntry<llvm::StringRef>::setValue(llvm::StringRef& pVal) 35{ 36 char* data = (char*)malloc(pVal.size()+1); 37 strcpy(data, pVal.data()); 38 m_Value = llvm::StringRef(data, pVal.size()); 39} 40 41void StringEntry<llvm::StringRef>::setValue(const char* pVal) 42{ 43 size_t length = strlen(pVal); 44 char* data = (char*)malloc(length+1); 45 strcpy(data, pVal); 46 m_Value = llvm::StringRef(data, length); 47} 48 49