[PATCH] D27475: [libFuzzer] Diff 17 - Implement DirName() for Windows.

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 14:03:39 PST 2016


amccarth added inline comments.


================
Comment at: lib/Fuzzer/FuzzerIOWindows.cpp:144
 std::string DirName(const std::string &FileName) {
-  assert(0 && "Unimplemented");
+  char *Tmp = new char[FileName.size() + 1];
+  memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
----------------
Instead of managing memory yourself, I would just use another string as the non-const buffer.  PathRemoveFileSpace may replace one of the characters with '\0', so all you have to do is resize the result.

    std::string result = FileName;
    PathRemoveFileSpecA(&result[0]);
    result.resize(std::strlen(result.c_str());
    return result;



Repository:
  rL LLVM

https://reviews.llvm.org/D27475





More information about the llvm-commits mailing list