Added to repository.
* Makefile.am: * glibtop_server.c: Added to repository. * glibtop_server.h: (get_scaled): Uninlined and moved it to glibtop_server.c. (skip_token) : Fixed indentation. * procmap.c: (glibtop_get_proc_map_s): Big cleanup. Better allocation algorithm. * procmem.c: * procsegment.c: Added missing initializations. * sem_limits.c: * shm_limits.c: (glibtop_get_shm_limits_s): * swap.c: * uptime.c: Added missing const qualifiers. * sysinfo.c: (init_sysinfo): Added missing 0 initialization. Saved 1 gboolean :D.
This commit is contained in:
23
sysdeps/linux/glibtop_server.c
Normal file
23
sysdeps/linux/glibtop_server.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned long long
|
||||
get_scaled(const char *buffer, const char *key)
|
||||
{
|
||||
const char *ptr;
|
||||
char *next;
|
||||
const size_t len = strlen(key);
|
||||
unsigned long long value = 0;
|
||||
|
||||
if ((ptr = strstr(buffer, key)))
|
||||
{
|
||||
ptr += len;
|
||||
value = strtoull(ptr, &next, 0);
|
||||
if (strchr(next, 'k'))
|
||||
value *= 1024;
|
||||
else if (strchr(next, 'M'))
|
||||
value *= 1024 * 1024;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user