mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-27 22:01:29 +02:00
extract delimiters
This commit is contained in:
parent
3db9d66476
commit
49d16cdddd
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user