1 //===- llvm/Support/StringSaver.h - Stable storage for strings --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_SUPPORT_STRINGSAVER_H
11 #define LLVM_SUPPORT_STRINGSAVER_H
13 #include "llvm/Support/Allocator.h"
18 /// \brief Saves strings in stable storage that it owns.
20 BumpPtrAllocator Alloc;
23 const char *saveCStr(const char *CStr) {
24 auto Len = std::strlen(CStr) + 1; // Don't forget the NUL!
25 char *Buf = Alloc.Allocate<char>(Len);
26 std::memcpy(Buf, CStr, Len);
31 } // end namespace llvm