Subversion Repositories Kolibri OS

Rev

Rev 5965 | Rev 5977 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5965 Rev 5974
Line 4... Line 4...
4
 
4
 
5
struct collection
5
struct collection
6
{
6
{
7
	int realloc_size, count;
7
	int realloc_size, count;
8
	dword data_start;
-
 
9
	dword data_cur_pos;
8
	dword data_start;
10
	dword data_size;
9
	dword data_size;
11
	dword element_offset[4090];
10
	dword element_offset[4090];
12
	int add();
11
	int add();
13
	dword get();
12
	dword get();
Line 29... Line 28...
29
	}
28
	}
30
}
29
}
Line 31... Line 30...
31
 
30
 
32
int collection::add(dword in) {
31
int collection::add(dword in) {
33
	if (count >= 4090) return 0;
32
	if (count >= 4090) return 0;
34
	if (data_cur_pos+strlen(in)+2 > data_size) {
33
	if (element_offset[count]+strlen(in)+2 > data_size) {
35
		increase_data_size();
34
		increase_data_size();
36
		add(in);
35
		add(in);
37
		return;
36
		return;
38
	}
37
	}
39
	strcpy(data_start+data_cur_pos, in);
-
 
40
	element_offset[count] = data_cur_pos;
-
 
41
	data_cur_pos += strlen(in) + 1;
38
	strcpy(data_start+element_offset[count], in);
-
 
39
	count++;
42
	count++;
40
	element_offset[count] = element_offset[count-1] + strlen(in) + 1;
43
	return 1;
41
	return 1;
Line 44... Line 42...
44
}
42
}
-
 
43
 
45
 
44
dword collection::get(dword pos) {
46
dword collection::get(dword pos) {
45
	if (pos<0) || (pos>=count) return 0;
Line 47... Line 46...
47
	return data_start + element_offset[pos];
46
	return data_start + element_offset[pos];
48
}
47
}
49
 
48
 
50
void collection::drop() {
49
void collection::drop() {
Line 51... Line 50...
51
	if (data_start) free(data_start);
50
	if (data_start) free(data_start);
52
	data_size = data_start = data_cur_pos = count = 0;
51
	data_size = data_start = element_offset[count] = count = 0;