forked from openshadowgate/shadowgate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_memory.c
69 lines (57 loc) · 1.86 KB
/
_memory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Update of the _minfo command to show more detailed information about what
// objects are using the most memory. -Ares
#include <std.h>
#include <daemons.h>
string header() { return ({ "%^RESET%^%^BLUE%^-=-=-=-=-=-=-=-=-=-=-=-=- %^RESET%^%^YELLOW%^Memory Statistics%^RESET%^%^BLUE%^ -=-=-=-=-=-=-=-=-=-=-=-=-\n\n" }); }
string footer() { return ({ "\n\n%^RESET%^%^BLUE%^-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" }); }
int compare(string one, string two)
{
int x,y;
one = one[64..strlen(one)];
two = two[64..strlen(two)];
x = to_int(one);
y = to_int(two);
return (y - x);
}
int cmd_memory(string str)
{
mapping stuff = ([]);
object *obs,ob;
string *display=({}),*items=({}),name;
int i,num,mem;
obs = objects();
obs -= ({0});
for(i=0;i<sizeof(obs);i++)
{
if(!objectp(obs[i])) { continue; }
name = base_name(obs[i]);
name = FILTERS_D->filter_colors(name);
//Added by Saide to allow for
//searching for a particular directory
if(strsrch(name, str) == -1 && str) continue;
if(!(stuff[name])) { stuff[name] = 1; }
else
{
num = stuff[name];
num += 1;
stuff[name] = num;
}
}
items = keys(stuff);
for(i=0;i<sizeof(items);i++)
{
name = items[i];
num = stuff[name];
ob = to_object(name);
if(objectp(ob)) { mem = memory_info(find_object_or_load(name)); }
else { mem = -1; }
mem = mem * num;
display += ({ " "+arrange_string(name,50)+" "+arrange_string(""+num+"",9)+""+mem+"" });
}
display = sort_array(display,"compare",TO);
display = ({ "%^RESET%^%^BOLD%^ "+arrange_string("File Name",50)+" Count Memory Usage\n" }) + display;
display = header() + display;
display += footer();
TP->more(display);
return 1;
}