[PATCH] D114337: Support Windows
Pavel Kosov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 25 04:47:56 PST 2021
kpdev42 marked 4 inline comments as done.
kpdev42 added inline comments.
================
Comment at: lnt/testing/profile/cPerf.cpp:63
+#define strtok_r strtok_s
+#include <windows.h>
+#include <BaseTsd.h>
----------------
danilaml wrote:
> Would it work with lean and mean macro defined? It's preferable, if it would.
Sure, I have updated the patch.
================
Comment at: lnt/testing/profile/cPerf.cpp:140
+#ifdef _WIN32
+size_t getline(char** lineptr, size_t* n, FILE* stream) {
+ if (lineptr == nullptr || stream == nullptr || n == nullptr) return -1;
----------------
danilaml wrote:
> shouldn't it return `ssize_t`?
Thanks! Fixed now.
================
Comment at: lnt/testing/profile/cPerf.cpp:154
+ while (c != EOF) {
+ if ((unsigned)(p - bufptr) > (size - 1)) {
+ size = size + 128;
----------------
danilaml wrote:
> Why cast to `unsigned`? What if `size == 0`?
Updated to ssize_t.
Note size = 0 must be provided only with lineprt = nullptr and then size is 128 after allocating bufptr. The behavior is undefined for non null lineprt and size = 0. Anyway, we have no such case here.
================
Comment at: lnt/testing/profile/cPerf.cpp:405
ssize_t Len = getline(&Line, &LineLen, Stream);
if (Len == -1)
break;
----------------
danilaml wrote:
> I think there is a potential mem leak here, but that's not critical.
Please look at the code `if (Line) free(Line);` below.
Repository:
rLNT LNT
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114337/new/
https://reviews.llvm.org/D114337
More information about the llvm-commits
mailing list