Subversion Repositories Kolibri OS

Rev

Rev 5965 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5959 leency 1
#ifndef INCLUDE_COLLECTION_H
2
#define INCLUDE_COLLECTION_H
3
#print "[include ]\n"
4
 
5
struct collection
6
{
7
	int count;
8
	dword element_offset[4096];
9
	dword data_size;
10
	dword string_data_start;
11
	dword string_data_cur_pos;
12
	void add();
13
	dword get();
14
	void drop();
15
	void init();
16
 
17
};
18
 
19
void collection::init(dword size) {
20
	if (data_size) drop();
21
	data_size = data_size + size;
22
	string_data_cur_pos = string_data_start = malloc(data_size);
23
	count = 0;
24
}
25
 
26
void collection::add(dword in) {
27
	strcpy(string_data_cur_pos, in);
28
	element_offset[count] = string_data_cur_pos;
29
	string_data_cur_pos += strlen(in) + 1;
30
	count++;
31
}
32
 
33
dword collection::get(dword pos) {
34
	return element_offset[pos];
35
}
36
 
37
void collection::drop() {
38
	if (string_data_start) free(string_data_start);
39
	data_size =
40
	string_data_start =
41
	string_data_cur_pos =
42
	count = 0;
43
}
44
 
45
#endif