extract delimiters

This commit is contained in:
Jos Dehaes 2021-10-02 23:51:29 +02:00 committed by aristocratos
parent 3db9d66476
commit 49d16cdddd

View File

@ -266,10 +266,11 @@ namespace Mem
char buf[512]; char buf[512];
while (fgets(buf, sizeof(buf), fpIn) != NULL) while (fgets(buf, sizeof(buf), fpIn) != NULL)
{ {
char *tokens = strtok(buf, ":\n."); char *delim = ":\n.";
char *tokens = strtok(buf, delim);
while (tokens) { while (tokens) {
char *label = tokens; char *label = tokens;
char *val = strtok(nullptr, ":\n."); char *val = strtok(nullptr, delim);
if (strstr(label, "Pages free")) if (strstr(label, "Pages free"))
{ {
uint64_t f = stoull(trim(val)); uint64_t f = stoull(trim(val));
@ -278,7 +279,7 @@ namespace Mem
// } else if (strstr(label, "Pages free")) { // } else if (strstr(label, "Pages free")) {
} }
tokens = strtok(nullptr, ":\n."); tokens = strtok(nullptr, delim);
} }
} }
pclose(fpIn); pclose(fpIn);