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 11 using namespace mcld; 12 13 //===----------------------------------------------------------------------===// 14 // StringEntry<llvm::StringRef> 15 //===----------------------------------------------------------------------===// StringEntry()16StringEntry<llvm::StringRef>::StringEntry() 17 { 18 } 19 StringEntry(const StringEntry::key_type & pKey)20StringEntry<llvm::StringRef>::StringEntry(const StringEntry::key_type& pKey) 21 { 22 } 23 StringEntry(const StringEntry<llvm::StringRef> & pCopy)24StringEntry<llvm::StringRef>::StringEntry(const StringEntry<llvm::StringRef>& pCopy) 25 { 26 assert("Copy constructor of StringEntry should not be called!"); 27 } 28 ~StringEntry()29StringEntry<llvm::StringRef>::~StringEntry() 30 { 31 if (!m_Value.empty()) 32 free(const_cast<char*>(m_Value.data())); 33 } 34 setValue(llvm::StringRef & pVal)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 setValue(const char * pVal)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