source: trunk/third/gstreamer/testsuite/refcounting/mem.c @ 21005

Revision 21005, 638 bytes checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <fcntl.h>
5#include <unistd.h>
6
7int
8vmsize ()
9{
10  int pid, fd, size, i, mem;
11  char filename[17], buf[256], *ptr, *end;
12
13  pid = getpid ();
14  snprintf (filename, 17, "/proc/%d/stat", pid);
15  fd = open (filename, O_RDONLY);
16  if (fd == -1) {
17    fprintf (stderr, "warning: could not open %s\n", filename);
18    return -1;
19  }
20  size = read (fd, buf, 240);
21  if (size == -1) return -1;
22  ptr = buf;
23  for (i = 0; i < 22; i++)
24    ptr = (char *) strchr (ptr, ' ') + 1;
25  end = (char *) strchr (ptr, ' ');
26  *end = 0;
27  sscanf (ptr, "%d", &mem);
28  close (fd);
29  return mem;
30}
Note: See TracBrowser for help on using the repository browser.