Rev 7049 | Rev 7771 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7049 | Rev 7286 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | dword get(); |
19 | dword get(); |
20 | void drop(); |
20 | void drop(); |
21 | void increase_data_size(); |
21 | void increase_data_size(); |
22 | }; |
22 | }; |
Line 23... | Line 23... | ||
23 | 23 | ||
24 | void collection::increase_data_size() { |
24 | :void collection::increase_data_size() { |
25 | int filled_size; |
25 | int filled_size; |
26 | if (realloc_size<4096) realloc_size = 4096; |
26 | if (realloc_size<4096) realloc_size = 4096; |
27 | if (!data_size) { |
27 | if (!data_size) { |
28 | data_size = realloc_size; |
28 | data_size = realloc_size; |
Line 32... | Line 32... | ||
32 | data_size = data_size + realloc_size; |
32 | data_size = data_size + realloc_size; |
33 | data_start = realloc(data_start, data_size); |
33 | data_start = realloc(data_start, data_size); |
34 | } |
34 | } |
35 | } |
35 | } |
Line 36... | Line 36... | ||
36 | 36 | ||
37 | int collection::add(dword in) { |
37 | :int collection::add(dword in) { |
38 | return addn(in, strlen(in)); |
38 | return addn(in, strlen(in)); |
Line 39... | Line 39... | ||
39 | } |
39 | } |
40 | 40 | ||
41 | int collection::addn(dword in, len) { |
41 | :int collection::addn(dword in, len) { |
42 | if (count >= 4000) return 0; |
42 | if (count >= 4000) return 0; |
43 | if (element_offset[count]+len+2 > data_size) { |
43 | if (element_offset[count]+len+2 > data_size) { |
44 | increase_data_size(); |
44 | increase_data_size(); |
Line 49... | Line 49... | ||
49 | count++; |
49 | count++; |
50 | element_offset[count] = element_offset[count-1] + len + 1; |
50 | element_offset[count] = element_offset[count-1] + len + 1; |
51 | return 1; |
51 | return 1; |
52 | } |
52 | } |
Line 53... | Line 53... | ||
53 | 53 | ||
54 | dword collection::get(dword pos) { |
54 | :dword collection::get(dword pos) { |
55 | if (pos<0) || (pos>=count) return 0; |
55 | if (pos<0) || (pos>=count) return 0; |
56 | return data_start + element_offset[pos]; |
56 | return data_start + element_offset[pos]; |
Line 57... | Line 57... | ||
57 | } |
57 | } |
58 | 58 | ||
59 | void collection::drop() { |
59 | :void collection::drop() { |
60 | if (data_start) free(data_start); |
60 | if (data_start) free(data_start); |
Line 72... | Line 72... | ||
72 | { |
72 | { |
73 | int count; |
73 | int count; |
74 | dword element[4096*3]; |
74 | dword element[4096*3]; |
75 | int add(); |
75 | int add(); |
76 | dword get(); |
76 | dword get(); |
- | 77 | dword get_last(); |
|
- | 78 | void pop(); |
|
77 | void drop(); |
79 | void drop(); |
78 | }; |
80 | }; |
Line 79... | Line 81... | ||
79 | 81 | ||
80 | int collection_int::add(dword in) { |
82 | :int collection_int::add(dword in) { |
81 | if (count >= 4096*3) return 0; |
83 | if (count >= 4096*3) return 0; |
82 | element[count] = in; |
84 | element[count] = in; |
83 | count++; |
85 | count++; |
84 | return 1; |
86 | return 1; |
Line 85... | Line 87... | ||
85 | } |
87 | } |
86 | 88 | ||
87 | dword collection_int::get(dword pos) { |
89 | :dword collection_int::get(dword pos) { |
88 | if (pos<0) || (pos>=count) return 0; |
90 | if (pos<0) || (pos>=count) return 0; |
Line -... | Line 91... | ||
- | 91 | return element[pos]; |
|
- | 92 | } |
|
- | 93 | ||
- | 94 | :dword collection_int::get_last() { |
|
- | 95 | return element[count]; |
|
- | 96 | } |
|
- | 97 | ||
- | 98 | :void collection_int::pop() { |
|
89 | return element[pos]; |
99 | if (count>0) count--; |
90 | } |
100 | } |
91 | 101 | ||
92 | void collection_int::drop() { |
102 | :void collection_int::drop() { |
Line 93... | Line 103... | ||
93 | element[0] = |
103 | element[0] = |
94 | count = 0; |
104 | count = 0; |