1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../embutils/free.patch
5 # Copyright (C) 2004 - 2006 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 A memory foodprint overview can be quite handy.
19 Rene Rebe <rene@exactcode.de>
21 --- ./Makefile~ 2006-08-03 12:54:04.000000000 +0200
22 +++ ./Makefile 2006-11-05 11:43:25.000000000 +0100
24 domainname id ln mv cp yes which cat rm wc ls whoami mkfifo head install \
25 sosrm soscp sosmv sosln soslns md5sum sleep2 allinone uniq tr mesg du \
26 uuencode uudecode nohup nice cmp mktemp truncate strings test date \
27 -printenv chrootuid renice
28 +printenv chrootuid renice \
33 --- /dev/null 2005-02-03 08:15:19.790903464 +0100
34 +++ embutils-0.17-free/free.c 2005-02-07 01:35:28.941469088 +0100
41 +/* Rene Rebe <rene@exactcode.de>
42 + * TODO: maybe support some options ... */
45 +#include "fmt_ulong.c"
46 +#include "fmt_ulongpadright.c"
48 +int main(int argc, char* argv[]) {
49 + int fd=open("/proc/meminfo",O_RDONLY);
51 + int len=read(fd,buf,4096);
56 + int val;} meminfo [] = {
69 + struct meminfo_t* i = &meminfo[0];
70 + char* tmp2 = strchr(line, ' ');
73 + for (;i->tag; i++) {
74 + if ( strcmp(line, i->tag) == 0 ) {
75 + tmp2++; while (*tmp2 == ' ') tmp2++;
77 + tmp2 = strchr(tmp2, '\n');
79 + i->val = atol(line);
85 + line = strchr(tmp2 + 1, '\n') + 1;
89 + len+=fmt_str (buf+len," total used free shared buffers cached\n");
91 + len+=fmt_str (buf+len, "Mem: ");
92 + len+=fmt_ulongpadright(buf+len,meminfo[0].val,10);
93 + buf[len]=' '; ++len;
94 + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val,10);
95 + buf[len]=' '; ++len;
96 + len+=fmt_ulongpadright(buf+len,meminfo[1].val,10);
97 + buf[len]=' '; ++len;
98 + len+=fmt_ulongpadright(buf+len,0,10);
99 + buf[len]=' '; ++len;
100 + len+=fmt_ulongpadright(buf+len,meminfo[2].val,10);
101 + buf[len]=' '; ++len;
102 + len+=fmt_ulongpadright(buf+len,meminfo[3].val,10);
103 + buf[len]='\n'; ++len;
105 + len += fmt_str (buf+len, "-/+ buffers/cache: ");
107 + int bc = meminfo[2].val + meminfo[3].val;
108 + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val - bc,10);
109 + buf[len]=' '; ++len;
110 + len+=fmt_ulongpadright(buf+len,meminfo[2].val + bc,10);
111 + buf[len]='\n'; ++len;
114 + len+=fmt_str (buf+len, "Swap: ");
115 + len+=fmt_ulongpadright(buf+len,meminfo[4].val,10);
116 + buf[len]=' '; ++len;
117 + len+=fmt_ulongpadright(buf+len,meminfo[4].val - meminfo[5].val,10);
118 + buf[len]=' '; ++len;
119 + len+=fmt_ulongpadright(buf+len,meminfo[5].val,10);