[Lldb-commits] [PATCH] Fix FileSpec::GetPath to return null-terminated strings
Ilia K
ki.stfu at gmail.com
Thu Feb 26 08:45:49 PST 2015
@zturner, one question about SmallString
================
Comment at: source/Host/macosx/HostInfoMacOSX.mm:137
@@ -136,3 +136,3 @@
return false;
char raw_path[PATH_MAX];
lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
----------------
clayborg wrote:
> zturner wrote:
> > Bonus points if you can get rid of all the c string manipulation in this function and write everything in terms of llvm::SmallString<> and llvm::StringRef. the basic idea is this:
> >
> > 1) Replace the stack buffer with an llvm::SmallString<PATH_MAX>.
> > 2) use SmallString<>::find() instead of strstr
> > 3) Construct a StringRef() with an explicit length instead of inserting a null terminator
> > 4) Use SmallString<>::replace() instead of strncpy
> > 5) use the file_spec.GetDirectory().SetString(StringRef) instead of file_spec.GetDirectory().SetCString(const char*)
> >
> > The same improvement could be made to the rest of the functions in this file.
> I would prefer to use std::string instead of llvm::SmallString.
>RE: 4. Use SmallString<>::replace() instead of strncpy
The replace() is absent. What I can use instead of it?
http://reviews.llvm.org/D7553
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the lldb-commits
mailing list