diff options
Diffstat (limited to 'testsuite/refcounting/mem.c')
-rw-r--r-- | testsuite/refcounting/mem.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/refcounting/mem.c b/testsuite/refcounting/mem.c new file mode 100644 index 0000000000..8e1c573bd4 --- /dev/null +++ b/testsuite/refcounting/mem.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> + +int vmsize() { + int pid,fd,size,i,mem; + char filename[17], buf[256], *ptr, *end; + + pid = getpid(); + snprintf(filename,17,"/proc/%d/stat",pid); + fd = open(filename,O_RDONLY); + size = read(fd,buf,240); + ptr = buf; + for (i=0;i<22;i++) + ptr = (char *)strchr(ptr,' ') + 1; + end = (char *)strchr(ptr,' '); + *end = 0; + sscanf(ptr,"%d",&mem); + close(fd); + return mem; +} |