[cfe-commits] r94313 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Benjamin Kramer benny.kra at googlemail.com
Sat Jan 23 10:16:07 PST 2010


Author: d0k
Date: Sat Jan 23 12:16:07 2010
New Revision: 94313

URL: http://llvm.org/viewvc/llvm-project?rev=94313&view=rev
Log:
No need to terminate this buffer.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=94313&r1=94312&r2=94313&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Jan 23 12:16:07 2010
@@ -78,10 +78,9 @@
   std::string NS = FD->getNameAsString();
 
   // Copy this name on the side and use its reference.
-  unsigned Length = NS.length() + 1;
-  char *StrPtr = FunctionNames.Allocate<char>(Length);
-  strncpy(StrPtr, NS.c_str(), Length);
-  return llvm::StringRef(StrPtr);
+  char *StrPtr = FunctionNames.Allocate<char>(NS.length());
+  memcpy(StrPtr, NS.data(), NS.length());
+  return llvm::StringRef(StrPtr, NS.length());
 }
 
 /// getOrCreateCompileUnit - Get the compile unit from the cache or create a new





More information about the cfe-commits mailing list