1 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # Filename: package/.../embutils/free.patch
5 # Copyright (C) 2007 The OpenSDE Project
6 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # More information can be found in the files COPYING and README.
10 # This patch file is dual-licensed. It is available under the license the
11 # patched project is licensed under, as long as it is an OpenSource license
12 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
13 # of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
16 # --- SDE-COPYRIGHT-NOTE-END ---
18 A memory foodprint overview can be quite handy.
20 Rene Rebe <rene@exactcode.de>
22 --- ./Makefile.orig 2007-03-28 00:46:09.000000000 -0400
23 +++ ./Makefile 2007-03-28 00:46:49.000000000 -0400
25 domainname id ln mv cp yes which cat rm wc ls whoami mkfifo head install \
26 sosrm soscp sosmv sosln soslns md5sum sleep2 allinone uniq tr mesg du \
27 uuencode uudecode nohup nice cmp mktemp truncate strings test date \
28 -printenv chrootuid renice
29 +printenv chrootuid renice free
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>
43 +/* TODO: maybe support some options ... */
46 +#include "fmt_ulong.c"
47 +#include "fmt_ulongpadright.c"
49 +int main(int argc, char* argv[]) {
50 + int fd=open("/proc/meminfo",O_RDONLY);
52 + int len=read(fd,buf,4096);
57 + int val;} meminfo [] = {
70 + struct meminfo_t* i = &meminfo[0];
71 + char* tmp2 = strchr(line, ' ');
74 + for (;i->tag; i++) {
75 + if ( strcmp(line, i->tag) == 0 ) {
76 + tmp2++; while (*tmp2 == ' ') tmp2++;
78 + tmp2 = strchr(tmp2, '\n');
80 + i->val = atol(line);
86 + line = strchr(tmp2 + 1, '\n') + 1;
90 + len+=fmt_str (buf+len," total used free shared buffers cached\n");
92 + len+=fmt_str (buf+len, "Mem: ");
93 + len+=fmt_ulongpadright(buf+len,meminfo[0].val,10);
94 + buf[len]=' '; ++len;
95 + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val,10);
96 + buf[len]=' '; ++len;
97 + len+=fmt_ulongpadright(buf+len,meminfo[1].val,10);
98 + buf[len]=' '; ++len;
99 + len+=fmt_ulongpadright(buf+len,0,10);
100 + buf[len]=' '; ++len;
101 + len+=fmt_ulongpadright(buf+len,meminfo[2].val,10);
102 + buf[len]=' '; ++len;
103 + len+=fmt_ulongpadright(buf+len,meminfo[3].val,10);
104 + buf[len]='\n'; ++len;
106 + len += fmt_str (buf+len, "-/+ buffers/cache: ");
108 + int bc = meminfo[2].val + meminfo[3].val;
109 + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val - bc,10);
110 + buf[len]=' '; ++len;
111 + len+=fmt_ulongpadright(buf+len,meminfo[2].val + bc,10);
112 + buf[len]='\n'; ++len;
115 + len+=fmt_str (buf+len, "Swap: ");
116 + len+=fmt_ulongpadright(buf+len,meminfo[4].val,10);
117 + buf[len]=' '; ++len;
118 + len+=fmt_ulongpadright(buf+len,meminfo[4].val - meminfo[5].val,10);
119 + buf[len]=' '; ++len;
120 + len+=fmt_ulongpadright(buf+len,meminfo[5].val,10);