Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dust1404 committed Aug 10, 2023
1 parent 36d8d8b commit 071255d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions unix/watcher_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ void cleanUp(int /*dummy*/) {

auto main(int /*argc*/, char *argv[]) -> int {
int timeLimit = 0;
size_t memoryLimit = 0;
ssize_t memoryLimit = 0; // 使用 ssize_t,当 memoryLimit<0 时表示无限制。
sscanf(argv[5], "%d", &timeLimit);
timeLimit = (timeLimit - 1) / 1000 + 1;
sscanf(argv[6], "%zu", &memoryLimit);
sscanf(argv[6], "%zd", &memoryLimit);
memoryLimit *= 1024 * 1024;

/* check static memory usage */
Expand All @@ -89,7 +89,7 @@ auto main(int /*argc*/, char *argv[]) -> int {
fileName = fileName.substr(0, fileName.find("\""));
char e_ident[EI_NIDENT];
ssize_t staticMemoryUsage = 0;
int fd = open(fileName.data(), O_RDONLY);
int fd = open(fileName.c_str(), O_RDONLY);
if (fd < 0) {
return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions unix/watcher_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ int main(int argc, char *argv[]) {
int isAppleSilicon = getCpuBrandString().find("Apple") != std::string::npos;

int timeLimit;
size_t memoryLimit;
ssize_t memoryLimit;
sscanf(argv[5], "%d", &timeLimit);
timeLimit = (timeLimit - 1) / 1000 + 1;
sscanf(argv[6], "%zu", &memoryLimit);
sscanf(argv[6], "%zd", &memoryLimit);

/* check static memory usage */
std::string fileName(argv[1]);
fileName = fileName.substr(1);
fileName = fileName.substr(0, fileName.find("\""));
uint32_t magic;
ssize_t staticMemoryUsage = 0;
int fd = open(fileName.data(), O_RDONLY);
int fd = open(fileName.c_str(), O_RDONLY);
if (fd < 0) {
return 1;
}
Expand Down

0 comments on commit 071255d

Please sign in to comment.