Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
66eb4a98
Commit
66eb4a98
authored
Jul 31, 2009
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function names changed in CycleStorage, TableBlockStorage
parent
34fb5e84
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
172 deletions
+119
-172
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+41
-43
Storages.h
include/Storages.h
+22
-25
CycleStorage.cc
src/Various/CycleStorage.cc
+21
-51
TableBlockStorage.cc
src/Various/TableBlockStorage.cc
+26
-25
TableStorage.cc
src/Various/TableStorage.cc
+9
-28
No files found.
Utilities/JrnTests/JrnTest.cc
View file @
66eb4a98
...
@@ -42,32 +42,32 @@ void testTable1(void)
...
@@ -42,32 +42,32 @@ void testTable1(void)
{
{
chr
[
0
]
=
i
;
chr
[
0
]
=
i
;
sprintf
(
val
,
"%d"
,
i
);
sprintf
(
val
,
"%d"
,
i
);
t
->
A
ddRow
(
chr
,
val
);
t
->
a
ddRow
(
chr
,
val
);
}
}
printf
(
"elements with values=keys added:
\n
"
);
printf
(
"elements with values=keys added:
\n
"
);
for
(
i
=
0
;
i
<
40
;
i
++
)
for
(
i
=
0
;
i
<
40
;
i
++
)
{
{
chr
[
0
]
=
i
;
chr
[
0
]
=
i
;
if
(
t
->
F
indKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
for
(
i
=
9
;
i
<
15
;
i
++
)
for
(
i
=
9
;
i
<
15
;
i
++
)
{
{
chr
[
0
]
=
i
;
chr
[
0
]
=
i
;
t
->
D
elRow
(
chr
);
t
->
d
elRow
(
chr
);
}
}
printf
(
"elements with keys from 9 to 14 deleted
\n
"
);
printf
(
"elements with keys from 9 to 14 deleted
\n
"
);
for
(
i
=
9
;
i
<
15
;
i
++
)
for
(
i
=
9
;
i
<
15
;
i
++
)
{
{
chr
[
0
]
=
i
;
chr
[
0
]
=
i
;
sprintf
(
val
,
"%d"
,
i
+
40
);
sprintf
(
val
,
"%d"
,
i
+
40
);
t
->
A
ddRow
(
chr
,
val
);
t
->
a
ddRow
(
chr
,
val
);
}
}
printf
(
"elements with keys from 9 to 14 with values=key+40 added, all elements:
\n
"
);
printf
(
"elements with keys from 9 to 14 with values=key+40 added, all elements:
\n
"
);
for
(
i
=
0
;
i
<
40
;
i
++
)
for
(
i
=
0
;
i
<
40
;
i
++
)
{
{
chr
[
0
]
=
i
;
chr
[
0
]
=
i
;
if
(
t
->
F
indKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -77,14 +77,14 @@ bool testTable2(void)
...
@@ -77,14 +77,14 @@ bool testTable2(void)
char
*
val
=
new
char
[
40
];
char
*
val
=
new
char
[
40
];
TableBlockStorage
*
t
;
TableBlockStorage
*
t
;
t
=
new
TableBlockStorage
();
t
=
new
TableBlockStorage
();
t
->
C
reate
(
"big_file.test"
,
4
,
40
,
20000
,
5
,
28
,
0
);
t
->
c
reate
(
"big_file.test"
,
4
,
40
,
20000
,
5
,
28
,
0
);
int
i
;
int
i
;
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
if
(
t
->
G
etCurBlock
()
!=
0
)
if
(
t
->
g
etCurBlock
()
!=
0
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
...
@@ -92,16 +92,16 @@ bool testTable2(void)
...
@@ -92,16 +92,16 @@ bool testTable2(void)
for
(
i
=
1
;
i
<
11
;
i
++
)
for
(
i
=
1
;
i
<
11
;
i
++
)
{
{
sprintf
(
val
,
"%d"
,
i
);
sprintf
(
val
,
"%d"
,
i
);
t
->
A
ddRow
((
char
*
)
&
i
,
val
);
t
->
a
ddRow
((
char
*
)
&
i
,
val
);
}
}
if
(
t
->
G
etCurBlock
()
!=
0
)
if
(
t
->
g
etCurBlock
()
!=
0
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
}
}
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
val
[
0
]
==
0
)
if
(
val
[
0
]
==
0
)
{
{
delete
t
;
delete
t
;
...
@@ -109,7 +109,7 @@ bool testTable2(void)
...
@@ -109,7 +109,7 @@ bool testTable2(void)
}
}
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
if
(
t
->
G
etCurBlock
()
!=
0
)
if
(
t
->
g
etCurBlock
()
!=
0
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
...
@@ -117,16 +117,16 @@ bool testTable2(void)
...
@@ -117,16 +117,16 @@ bool testTable2(void)
for
(
i
=
1
;
i
<
8
;
i
++
)
for
(
i
=
1
;
i
<
8
;
i
++
)
{
{
sprintf
(
val
,
"%d"
,
i
+
10
);
sprintf
(
val
,
"%d"
,
i
+
10
);
t
->
A
ddRow
(
&
i
,
val
);
t
->
a
ddRow
(
&
i
,
val
);
}
}
printf
(
"deleteing 8-10 elements
\n
"
);
printf
(
"deleteing 8-10 elements
\n
"
);
for
(
i
=
8
;
i
<
11
;
i
++
)
for
(
i
=
8
;
i
<
11
;
i
++
)
{
{
t
->
D
elRow
(
&
i
);
t
->
d
elRow
(
&
i
);
}
}
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
(
&
i
,
val
)
!=
0
)
if
(
t
->
f
indKeyValue
(
&
i
,
val
)
!=
0
)
{
{
printf
(
"%s, "
,
val
);
printf
(
"%s, "
,
val
);
if
((
i
>
7
)
&&
(
i
<
11
))
if
((
i
>
7
)
&&
(
i
<
11
))
...
@@ -142,7 +142,7 @@ bool testTable2(void)
...
@@ -142,7 +142,7 @@ bool testTable2(void)
}
}
}
}
printf
(
"
\n
rewriting 3-10 elements with values=keys+40
\n
"
);
printf
(
"
\n
rewriting 3-10 elements with values=keys+40
\n
"
);
if
(
t
->
G
etCurBlock
()
!=
0
)
if
(
t
->
g
etCurBlock
()
!=
0
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
...
@@ -150,11 +150,11 @@ bool testTable2(void)
...
@@ -150,11 +150,11 @@ bool testTable2(void)
for
(
i
=
3
;
i
<
11
;
i
++
)
for
(
i
=
3
;
i
<
11
;
i
++
)
{
{
sprintf
(
val
,
"%d"
,
i
+
40
);
sprintf
(
val
,
"%d"
,
i
+
40
);
t
->
A
ddRow
(
&
i
,
val
);
t
->
a
ddRow
(
&
i
,
val
);
}
}
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
((
atoi
(
val
)
!=
i
+
40
)
&&
(
i
>
2
)
&&
(
i
<
11
))
if
((
atoi
(
val
)
!=
i
+
40
)
&&
(
i
>
2
)
&&
(
i
<
11
))
{
{
delete
t
;
delete
t
;
...
@@ -166,7 +166,7 @@ bool testTable2(void)
...
@@ -166,7 +166,7 @@ bool testTable2(void)
return
false
;
return
false
;
}
}
}
}
if
(
t
->
G
etCurBlock
()
!=
0
)
if
(
t
->
g
etCurBlock
()
!=
0
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
...
@@ -174,23 +174,23 @@ bool testTable2(void)
...
@@ -174,23 +174,23 @@ bool testTable2(void)
strcpy
(
val
,
"new block"
);
strcpy
(
val
,
"new block"
);
i
=
9
;
i
=
9
;
t
->
A
ddRow
(
&
i
,
val
);
t
->
a
ddRow
(
&
i
,
val
);
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
((
char
*
)
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
((
char
*
)
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
}
if
(
t
->
G
etCurBlock
()
!=
1
)
if
(
t
->
g
etCurBlock
()
!=
1
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
}
}
printf
(
"after reopen:
\n
"
);
printf
(
"after reopen:
\n
"
);
t
->
O
pen
(
"big_file.test"
,
4
,
40
,
20000
,
5
,
28
,
0
);
t
->
o
pen
(
"big_file.test"
,
4
,
40
,
20000
,
5
,
28
,
0
);
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
}
if
(
t
->
G
etCurBlock
()
!=
1
)
if
(
t
->
g
etCurBlock
()
!=
1
)
{
{
delete
t
;
delete
t
;
return
false
;
return
false
;
...
@@ -209,12 +209,12 @@ bool testJournal1(void)
...
@@ -209,12 +209,12 @@ bool testJournal1(void)
for
(
i
=
1
;
i
<
33000
;
i
++
)
for
(
i
=
1
;
i
<
33000
;
i
++
)
{
{
sprintf
(
str
,
"%d"
,
i
);
sprintf
(
str
,
"%d"
,
i
);
j
->
A
ddRow
(
str
);
j
->
a
ddRow
(
str
);
}
}
printf
(
"first 30 elements:
\n
"
);
printf
(
"first 30 elements:
\n
"
);
for
(
i
=
0
;
i
<
30
;
i
++
)
for
(
i
=
0
;
i
<
30
;
i
++
)
{
{
if
(
j
->
R
eadRow
(
i
,
str
))
if
(
j
->
r
eadRow
(
i
,
str
))
{
{
printf
(
"%s
\n
"
,
str
);
printf
(
"%s
\n
"
,
str
);
k
++
;
k
++
;
...
@@ -232,7 +232,7 @@ bool testJournal1(void)
...
@@ -232,7 +232,7 @@ bool testJournal1(void)
char
*
val
=
new
char
[
40
];
char
*
val
=
new
char
[
40
];
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
->
F
indKeyValue
((
char
*
)
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
->
f
indKeyValue
((
char
*
)
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
((
atoi
(
val
)
!=
i
+
10
)
&&
(
i
<
3
))
if
((
atoi
(
val
)
!=
i
+
10
)
&&
(
i
<
3
))
{
{
delete
t
;
delete
t
;
...
@@ -244,11 +244,11 @@ bool testJournal1(void)
...
@@ -244,11 +244,11 @@ bool testJournal1(void)
printf
(
"
\n
first 30 elements after deleting first 20:
\n
"
);
printf
(
"
\n
first 30 elements after deleting first 20:
\n
"
);
for
(
i
=
0
;
i
<
20
;
i
++
)
for
(
i
=
0
;
i
<
20
;
i
++
)
{
{
j
->
D
elRow
(
i
);
j
->
d
elRow
(
i
);
}
}
for
(
i
=
0
;
i
<
30
;
i
++
)
for
(
i
=
0
;
i
<
30
;
i
++
)
{
{
if
(
j
->
R
eadRow
(
i
,
str
))
if
(
j
->
r
eadRow
(
i
,
str
))
{
{
printf
(
"%s
\n
"
,
str
);
printf
(
"%s
\n
"
,
str
);
k
++
;
k
++
;
...
@@ -266,11 +266,11 @@ bool testJournal1(void)
...
@@ -266,11 +266,11 @@ bool testJournal1(void)
for
(
i
=
10001
;
i
<
10011
;
i
++
)
for
(
i
=
10001
;
i
<
10011
;
i
++
)
{
{
sprintf
(
str
,
"%d"
,
i
);
sprintf
(
str
,
"%d"
,
i
);
j
->
A
ddRow
(
str
);
j
->
a
ddRow
(
str
);
}
}
for
(
i
=
0
;
i
<
20
;
i
++
)
for
(
i
=
0
;
i
<
20
;
i
++
)
{
{
if
(
j
->
R
eadRow
(
i
,
str
))
if
(
j
->
r
eadRow
(
i
,
str
))
{
{
printf
(
"%s
\n
"
,
str
);
printf
(
"%s
\n
"
,
str
);
k
++
;
k
++
;
...
@@ -285,12 +285,11 @@ bool testJournal1(void)
...
@@ -285,12 +285,11 @@ bool testJournal1(void)
k
=
0
;
k
=
0
;
printf
(
"the same after reopen:
\n
"
);
printf
(
"the same after reopen:
\n
"
);
delete
j
;
j
=
new
CycleStorage
();
j
=
new
CycleStorage
();
j
->
O
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
j
->
o
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
for
(
i
=
0
;
i
<
20
;
i
++
)
for
(
i
=
0
;
i
<
20
;
i
++
)
{
{
if
(
j
->
R
eadRow
(
i
,
str
))
if
(
j
->
r
eadRow
(
i
,
str
))
{
{
printf
(
"%s
\n
"
,
str
);
printf
(
"%s
\n
"
,
str
);
k
++
;
k
++
;
...
@@ -305,12 +304,11 @@ bool testJournal1(void)
...
@@ -305,12 +304,11 @@ bool testJournal1(void)
k
=
0
;
k
=
0
;
printf
(
"the same after reopen:
\n
"
);
printf
(
"the same after reopen:
\n
"
);
delete
j
;
j
=
new
CycleStorage
();
j
=
new
CycleStorage
();
j
->
O
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
j
->
o
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
for
(
i
=
0
;
i
<
20
;
i
++
)
for
(
i
=
0
;
i
<
20
;
i
++
)
{
{
if
(
j
->
R
eadRow
(
i
,
str
))
if
(
j
->
r
eadRow
(
i
,
str
))
{
{
printf
(
"%s
\n
"
,
str
);
printf
(
"%s
\n
"
,
str
);
k
++
;
k
++
;
...
@@ -320,7 +318,7 @@ bool testJournal1(void)
...
@@ -320,7 +318,7 @@ bool testJournal1(void)
{
{
delete
t
;
delete
t
;
delete
j
;
delete
j
;
//
return false;
return
false
;
}
}
delete
t
;
delete
t
;
...
@@ -335,16 +333,16 @@ void testJournal2(void)
...
@@ -335,16 +333,16 @@ void testJournal2(void)
char
*
str
=
(
char
*
)
malloc
(
30
);
char
*
str
=
(
char
*
)
malloc
(
30
);
j
=
new
CycleStorage
(
"big_file.test"
,
30
,
1000000
,
20000
);
j
=
new
CycleStorage
(
"big_file.test"
,
30
,
1000000
,
20000
);
printf
(
"journal test 2 - checking number of iterations to find head/tail
\n
"
);
printf
(
"journal test 2 - checking number of iterations to find head/tail
\n
"
);
printf
(
"iterations = %d
\n
"
,
j
->
G
etIter
());
printf
(
"iterations = %d
\n
"
,
j
->
g
etIter
());
for
(
i
=
0
;
i
<
20
;
i
++
)
for
(
i
=
0
;
i
<
20
;
i
++
)
{
{
for
(
k
=
1000
;
k
<
3000
;
k
++
)
for
(
k
=
1000
;
k
<
3000
;
k
++
)
{
{
sprintf
(
str
,
"%d"
,
k
);
sprintf
(
str
,
"%d"
,
k
);
j
->
A
ddRow
(
str
);
j
->
a
ddRow
(
str
);
}
}
j
->
O
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
j
->
o
pen
(
"big_file.test"
,
30
,
1000000
,
20000
);
printf
(
"iterations = %d
\n
"
,
j
->
G
etIter
());
printf
(
"iterations = %d
\n
"
,
j
->
g
etIter
());
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
delete
j
;
delete
j
;
...
...
include/Storages.h
View file @
66eb4a98
...
@@ -79,9 +79,9 @@ class TableStorage
...
@@ -79,9 +79,9 @@ class TableStorage
public
:
public
:
TableStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
TableStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
~
TableStorage
();
~
TableStorage
();
int
A
ddRow
(
char
*
key
,
char
*
val
);
int
a
ddRow
(
char
*
key
,
char
*
val
);
int
D
elRow
(
char
*
key
);
int
d
elRow
(
char
*
key
);
char
*
F
indKeyValue
(
char
*
key
,
char
*
val
);
char
*
f
indKeyValue
(
char
*
key
,
char
*
val
);
};
};
class
TableBlockStorage
class
TableBlockStorage
...
@@ -100,20 +100,20 @@ class TableBlockStorage
...
@@ -100,20 +100,20 @@ class TableBlockStorage
block_num - - ( = sz/block_num
block_num - - ( = sz/block_num
, ), block_lim - ,
, ), block_lim - ,
seek - ( , ) */
seek - ( , ) */
bool
O
pen
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
o
pen
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
C
reate
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
c
reate
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
);
/*! , */
/*! , */
bool
A
ddRow
(
void
*
key
,
void
*
val
);
bool
a
ddRow
(
void
*
key
,
void
*
val
);
/*! , , */
/*! , , */
bool
D
elRow
(
void
*
key
);
bool
d
elRow
(
void
*
key
);
/*! , 0 */
/*! , 0 */
void
*
F
indKeyValue
(
void
*
key
,
void
*
val
);
void
*
f
indKeyValue
(
void
*
key
,
void
*
val
);
/*! ( ) */
/*! ( ) */
int
G
etCurBlock
(
void
);
int
g
etCurBlock
(
void
);
protected
:
protected
:
FILE
*
file
;
FILE
*
file
;
int
inf_size
;
int
inf_size
;
...
@@ -123,10 +123,10 @@ class TableBlockStorage
...
@@ -123,10 +123,10 @@ class TableBlockStorage
int
k_size
,
lim
,
seekpos
;
int
k_size
,
lim
,
seekpos
;
int
size
,
block_size
,
block_number
,
full_size
;
int
size
,
block_size
,
block_number
,
full_size
;
void
filewrite
(
int
seek
,
bool
needflush
=
true
);
void
filewrite
(
int
seek
,
bool
needflush
=
true
);
bool
C
opyToNextBlock
();
bool
c
opyToNextBlock
();
bool
K
eyCompare
(
int
i
,
void
*
key
);
bool
k
eyCompare
(
int
i
,
void
*
key
);
void
*
K
eyPointer
(
int
num
);
void
*
k
eyPointer
(
int
num
);
void
*
V
alPointer
(
int
num
);
void
*
v
alPointer
(
int
num
);
};
};
class
CycleStorage
class
CycleStorage
...
@@ -143,26 +143,23 @@ class CycleStorage
...
@@ -143,26 +143,23 @@ class CycleStorage
/*! inf_sz - , sz - ,
/*! inf_sz - , sz - ,
seek - ( , ) */
seek - ( , ) */
bool
O
pen
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
bool
o
pen
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
bool
C
reate
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
bool
c
reate
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
/*! */
/*! */
bool
A
ddRow
(
void
*
str
);
bool
a
ddRow
(
void
*
str
);
/*! row */
/*! row */
bool
D
elRow
(
int
row
);
bool
d
elRow
(
int
row
);
/*! */
/*! */
bool
D
elAllRows
(
void
);
bool
d
elAllRows
(
void
);
/*! num */
/*! num */
void
*
ReadRow
(
int
num
,
void
*
str
);
void
*
readRow
(
int
num
,
void
*
str
);
/*! Xml- name */
//bool ExportToXML(const char* name);
/*! - / ( ) */
/*! - / ( ) */
int
G
etIter
(
void
);
int
g
etIter
(
void
);
protected
:
protected
:
FILE
*
file
;
FILE
*
file
;
int
inf_size
;
int
inf_size
;
...
@@ -171,8 +168,8 @@ class CycleStorage
...
@@ -171,8 +168,8 @@ class CycleStorage
int
size
,
seekpos
,
iter
;
int
size
,
seekpos
,
iter
;
int
full_size
;
int
full_size
;
void
filewrite
(
CycleStorageElem
*
jrn
,
int
seek
,
bool
needflush
=
true
);
void
filewrite
(
CycleStorageElem
*
jrn
,
int
seek
,
bool
needflush
=
true
);
void
*
V
alPointer
(
void
*
pnt
);
void
*
v
alPointer
(
void
*
pnt
);
void
F
indHead
();
void
f
indHead
();
};
};
#endif
#endif
src/Various/CycleStorage.cc
View file @
66eb4a98
...
@@ -35,13 +35,13 @@ CycleStorage::CycleStorage()
...
@@ -35,13 +35,13 @@ CycleStorage::CycleStorage()
file
=
NULL
;
file
=
NULL
;
}
}
CycleStorage
::
CycleStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
,
bool
cr
eate
)
CycleStorage
::
CycleStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
,
bool
cr
)
{
{
file
=
NULL
;
file
=
NULL
;
if
(
!
O
pen
(
name
,
inf_sz
,
sz
,
seek
))
if
(
!
o
pen
(
name
,
inf_sz
,
sz
,
seek
))
{
{
if
(
cr
eate
)
if
(
cr
)
C
reate
(
name
,
inf_sz
,
sz
,
seek
);
c
reate
(
name
,
inf_sz
,
sz
,
seek
);
else
else
file
=
NULL
;
file
=
NULL
;
}
}
...
@@ -52,7 +52,7 @@ CycleStorage::~CycleStorage()
...
@@ -52,7 +52,7 @@ CycleStorage::~CycleStorage()
fclose
(
file
);
fclose
(
file
);
}
}
void
*
CycleStorage
::
V
alPointer
(
void
*
pnt
)
void
*
CycleStorage
::
v
alPointer
(
void
*
pnt
)
{
{
return
(
char
*
)
pnt
+
sizeof
(
CycleStorageElem
);
return
(
char
*
)
pnt
+
sizeof
(
CycleStorageElem
);
}
}
...
@@ -68,7 +68,7 @@ void CycleStorage::filewrite(CycleStorageElem* jrn,int seek,bool needflush)
...
@@ -68,7 +68,7 @@ void CycleStorage::filewrite(CycleStorageElem* jrn,int seek,bool needflush)
( 2 - 4 , ), 3 - 2, 5 - 4, 6 - 1.
( 2 - 4 , ), 3 - 2, 5 - 4, 6 - 1.
|
|
*/
*/
void
CycleStorage
::
F
indHead
()
void
CycleStorage
::
f
indHead
()
{
{
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
int
l
=-
1
,
r
=
size
,
mid
;
int
l
=-
1
,
r
=
size
,
mid
;
...
@@ -134,7 +134,7 @@ void CycleStorage::FindHead()
...
@@ -134,7 +134,7 @@ void CycleStorage::FindHead()
delete
jrn
;
delete
jrn
;
}
}
bool
CycleStorage
::
O
pen
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
)
bool
CycleStorage
::
o
pen
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
)
{
{
/*! ,
/*! ,
*/
*/
...
@@ -165,12 +165,12 @@ bool CycleStorage::Open(const char* name, int inf_sz, int sz, int seek)
...
@@ -165,12 +165,12 @@ bool CycleStorage::Open(const char* name, int inf_sz, int sz, int seek)
seekpos
+=
sizeof
(
CycleStorageAttr
);
seekpos
+=
sizeof
(
CycleStorageAttr
);
F
indHead
();
f
indHead
();
return
true
;
return
true
;
}
}
bool
CycleStorage
::
C
reate
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
)
bool
CycleStorage
::
c
reate
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
)
{
{
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
file
=
fopen
(
name
,
"r+"
);
...
@@ -203,6 +203,7 @@ bool CycleStorage::Create(const char* name, int inf_sz, int sz, int seek)
...
@@ -203,6 +203,7 @@ bool CycleStorage::Create(const char* name, int inf_sz, int sz, int seek)
fwrite
(
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
fwrite
(
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
fflush
(
file
);
fflush
(
file
);
seekpos
+=
sizeof
(
CycleStorageAttr
);
seekpos
+=
sizeof
(
CycleStorageAttr
);
delete
csa
;
/*! */
/*! */
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
...
@@ -222,12 +223,11 @@ bool CycleStorage::Create(const char* name, int inf_sz, int sz, int seek)
...
@@ -222,12 +223,11 @@ bool CycleStorage::Create(const char* name, int inf_sz, int sz, int seek)
}
}
head
=
tail
=-
1
;
head
=
tail
=-
1
;
delete
csa
;
delete
jrn
;
delete
jrn
;
return
true
;
return
true
;
}
}
bool
CycleStorage
::
A
ddRow
(
void
*
str
)
bool
CycleStorage
::
a
ddRow
(
void
*
str
)
{
{
if
(
file
==
NULL
)
return
false
;
if
(
file
==
NULL
)
return
false
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
...
@@ -236,7 +236,7 @@ bool CycleStorage::AddRow(void* str)
...
@@ -236,7 +236,7 @@ bool CycleStorage::AddRow(void* str)
/*! 2 - (head=-1), 1 (head=tail=0) )
/*! 2 - (head=-1), 1 (head=tail=0) )
*/
*/
memcpy
(
V
alPointer
(
jrn
),
str
,
inf_size
);
memcpy
(
v
alPointer
(
jrn
),
str
,
inf_size
);
if
(
head
==-
1
)
if
(
head
==-
1
)
{
{
jrn
->
status
=
1
;
jrn
->
status
=
1
;
...
@@ -276,7 +276,7 @@ bool CycleStorage::AddRow(void* str)
...
@@ -276,7 +276,7 @@ bool CycleStorage::AddRow(void* str)
}
}
else
tail
++
;
else
tail
++
;
fread
(
jrn
,
full_size
,
1
,
file
);
fread
(
jrn
,
full_size
,
1
,
file
);
memcpy
(
V
alPointer
(
jrn
),
str
,
inf_size
);
memcpy
(
v
alPointer
(
jrn
),
str
,
inf_size
);
if
(
jrn
->
status
==
0
)
if
(
jrn
->
status
==
0
)
{
{
jrn
->
status
=
2
;
jrn
->
status
=
2
;
...
@@ -302,7 +302,7 @@ bool CycleStorage::AddRow(void* str)
...
@@ -302,7 +302,7 @@ bool CycleStorage::AddRow(void* str)
return
true
;
return
true
;
}
}
bool
CycleStorage
::
D
elRow
(
int
row
)
bool
CycleStorage
::
d
elRow
(
int
row
)
{
{
int
i
=
(
head
+
row
)
%
size
,
j
;
int
i
=
(
head
+
row
)
%
size
,
j
;
if
(
row
>=
size
)
return
false
;
if
(
row
>=
size
)
return
false
;
...
@@ -334,7 +334,7 @@ bool CycleStorage::DelRow(int row)
...
@@ -334,7 +334,7 @@ bool CycleStorage::DelRow(int row)
return
true
;
return
true
;
}
}
bool
CycleStorage
::
D
elAllRows
()
bool
CycleStorage
::
d
elAllRows
()
{
{
/*! */
/*! */
if
(
file
==
NULL
)
return
false
;
if
(
file
==
NULL
)
return
false
;
...
@@ -357,7 +357,8 @@ bool CycleStorage::DelAllRows()
...
@@ -357,7 +357,8 @@ bool CycleStorage::DelAllRows()
return
true
;
return
true
;
}
}
void
*
CycleStorage
::
ReadRow
(
int
num
,
void
*
str
)
/*! TODO: str, */
void
*
CycleStorage
::
readRow
(
int
num
,
void
*
str
)
{
{
/*! */
/*! */
int
j
=
(
head
+
num
)
%
size
;
int
j
=
(
head
+
num
)
%
size
;
...
@@ -369,47 +370,15 @@ void* CycleStorage::ReadRow(int num, void* str)
...
@@ -369,47 +370,15 @@ void* CycleStorage::ReadRow(int num, void* str)
fread
(
jrn
,
full_size
,
1
,
file
);
fread
(
jrn
,
full_size
,
1
,
file
);
if
((
jrn
->
status
==
1
)
||
(
jrn
->
status
==
2
)
||
(
jrn
->
status
==
4
))
if
((
jrn
->
status
==
1
)
||
(
jrn
->
status
==
2
)
||
(
jrn
->
status
==
4
))
{
{
memcpy
(
str
,
V
alPointer
(
jrn
),
inf_size
);
memcpy
(
str
,
v
alPointer
(
jrn
),
inf_size
);
delete
jrn
;
delete
jrn
;
return
str
;
return
str
;
}
}
delete
jrn
;
delete
jrn
;
return
0
;
return
NULL
;
}
}
/*bool CycleStorage::ExportToXML(const char* name)
int
CycleStorage
::
getIter
()
{
int i,j=head;
if(file==NULL) return false;
CycleStorageElem *jrn = (CycleStorageElem*)new char[full_size];
UniXML* f = new UniXML();
xmlNode* xn;
f->newDoc("journal");
fseek(file,seekpos+j*full_size,0);
char* num = new char[10];
for(i=0;i<size;i++)
{
if(j==size)
{
j=0;
fseek(file,seekpos,0);
}
fread(jrn,full_size,1,file);
if((jrn->status==1)||(jrn->status==2)||(jrn->status==4))
{
sprintf(num,"%d",i);
xn=f->createChild(f->cur,"item","");
f->setProp(xn,"key",num);
f->setProp(xn,"text",(char*)ValPointer(jrn));
}
j++;
}
f->save(name);
delete jrn;
return true;
}*/
int
CycleStorage
::
GetIter
()
{
{
return
iter
;
return
iter
;
}
}
\ No newline at end of file
src/Various/TableBlockStorage.cc
View file @
66eb4a98
...
@@ -35,13 +35,13 @@ TableBlockStorage::TableBlockStorage()
...
@@ -35,13 +35,13 @@ TableBlockStorage::TableBlockStorage()
file
=
NULL
;
file
=
NULL
;
}
}
TableBlockStorage
::
TableBlockStorage
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
cr
eate
)
TableBlockStorage
::
TableBlockStorage
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
cr
)
{
{
file
=
NULL
;
file
=
NULL
;
if
(
!
O
pen
(
name
,
key_sz
,
inf_sz
,
sz
,
block_num
,
block_lim
,
seek
))
if
(
!
o
pen
(
name
,
key_sz
,
inf_sz
,
sz
,
block_num
,
block_lim
,
seek
))
{
{
if
(
cr
eate
)
if
(
cr
)
C
reate
(
name
,
key_sz
,
inf_sz
,
sz
,
block_num
,
block_lim
,
seek
);
c
reate
(
name
,
key_sz
,
inf_sz
,
sz
,
block_num
,
block_lim
,
seek
);
else
else
file
=
NULL
;
file
=
NULL
;
}
}
...
@@ -58,17 +58,17 @@ TableBlockStorage::~TableBlockStorage()
...
@@ -58,17 +58,17 @@ TableBlockStorage::~TableBlockStorage()
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
}
}
bool
TableBlockStorage
::
K
eyCompare
(
int
i
,
void
*
key
)
bool
TableBlockStorage
::
k
eyCompare
(
int
i
,
void
*
key
)
{
{
return
!
memcmp
((
char
*
)
mem
[
i
]
+
sizeof
(
TableBlockStorageElem
),
key
,
k_size
);
return
!
memcmp
((
char
*
)
mem
[
i
]
+
sizeof
(
TableBlockStorageElem
),
key
,
k_size
);
}
}
void
*
TableBlockStorage
::
K
eyPointer
(
int
num
)
void
*
TableBlockStorage
::
k
eyPointer
(
int
num
)
{
{
return
(
char
*
)
mem
[
num
]
+
sizeof
(
TableBlockStorageElem
);
return
(
char
*
)
mem
[
num
]
+
sizeof
(
TableBlockStorageElem
);
}
}
void
*
TableBlockStorage
::
V
alPointer
(
int
num
)
void
*
TableBlockStorage
::
v
alPointer
(
int
num
)
{
{
return
(
char
*
)
mem
[
num
]
+
sizeof
(
TableBlockStorageElem
)
+
k_size
;
return
(
char
*
)
mem
[
num
]
+
sizeof
(
TableBlockStorageElem
)
+
k_size
;
}
}
...
@@ -81,7 +81,7 @@ void TableBlockStorage::filewrite(int seek, bool needflush)
...
@@ -81,7 +81,7 @@ void TableBlockStorage::filewrite(int seek, bool needflush)
if
(
needflush
)
fflush
(
file
);
if
(
needflush
)
fflush
(
file
);
}
}
bool
TableBlockStorage
::
C
opyToNextBlock
(
void
)
bool
TableBlockStorage
::
c
opyToNextBlock
(
void
)
{
{
/*! */
/*! */
max
=-
1
;
max
=-
1
;
...
@@ -114,7 +114,7 @@ bool TableBlockStorage::CopyToNextBlock(void)
...
@@ -114,7 +114,7 @@ bool TableBlockStorage::CopyToNextBlock(void)
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
O
pen
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
)
bool
TableBlockStorage
::
o
pen
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
)
{
{
/*! , */
/*! , */
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
...
@@ -183,7 +183,7 @@ bool TableBlockStorage::Open(const char* name, int key_sz, int inf_sz, int sz, i
...
@@ -183,7 +183,7 @@ bool TableBlockStorage::Open(const char* name, int key_sz, int inf_sz, int sz, i
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
C
reate
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
)
bool
TableBlockStorage
::
c
reate
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
sz
,
int
block_num
,
int
block_lim
,
int
seek
)
{
{
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
file
=
fopen
(
name
,
"r+"
);
...
@@ -229,6 +229,7 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
...
@@ -229,6 +229,7 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
fwrite
(
sa
,
sizeof
(
StorageAttr
),
1
,
file
);
fwrite
(
sa
,
sizeof
(
StorageAttr
),
1
,
file
);
fflush
(
file
);
fflush
(
file
);
seekpos
+=
sizeof
(
StorageAttr
);
seekpos
+=
sizeof
(
StorageAttr
);
delete
sa
;
/*! :
/*! :
EMPTY_BLOCK=(-5) - , , , EMPTY_ELEM=(-1) -
EMPTY_BLOCK=(-5) - , , , EMPTY_ELEM=(-1) -
...
@@ -255,48 +256,47 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
...
@@ -255,48 +256,47 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
fwrite
(
empty
,
emp
,
1
,
file
);
fwrite
(
empty
,
emp
,
1
,
file
);
fflush
(
file
);
fflush
(
file
);
}
}
delete
sa
;
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
A
ddRow
(
void
*
key
,
void
*
value
)
bool
TableBlockStorage
::
a
ddRow
(
void
*
key
,
void
*
value
)
{
{
int
i
=
0
,
pos
=-
1
,
empty
=-
1
;
int
i
=
0
,
pos
=-
1
,
empty
=-
1
;
if
(
file
==
NULL
)
return
false
;
if
(
file
==
NULL
)
return
false
;
if
(
max
==
lim
-
1
)
C
opyToNextBlock
();
if
(
max
==
lim
-
1
)
c
opyToNextBlock
();
for
(
i
=
0
;
i
<
block_size
;
i
++
)
for
(
i
=
0
;
i
<
block_size
;
i
++
)
{
{
if
(
mem
[
i
]
->
count
>=
0
)
if
(
mem
[
i
]
->
count
>=
0
)
if
(
K
eyCompare
(
i
,
key
))
pos
=
i
;
if
(
k
eyCompare
(
i
,
key
))
pos
=
i
;
if
((
mem
[
i
]
->
count
<
0
)
&&
(
empty
<
0
))
empty
=
i
;
if
((
mem
[
i
]
->
count
<
0
)
&&
(
empty
<
0
))
empty
=
i
;
}
}
/*! , pos>=0, , empty */
/*! , pos>=0, , empty */
if
(
pos
>=
0
)
empty
=
pos
;
if
(
pos
>=
0
)
empty
=
pos
;
else
memcpy
(
K
eyPointer
(
empty
),
key
,
k_size
);
else
memcpy
(
k
eyPointer
(
empty
),
key
,
k_size
);
mem
[
empty
]
->
count
=++
max
;
mem
[
empty
]
->
count
=++
max
;
memcpy
(
V
alPointer
(
empty
),
value
,
inf_size
);
memcpy
(
v
alPointer
(
empty
),
value
,
inf_size
);
filewrite
(
empty
);
filewrite
(
empty
);
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
D
elRow
(
void
*
key
)
bool
TableBlockStorage
::
d
elRow
(
void
*
key
)
{
{
int
i
;
int
i
;
if
(
file
==
NULL
)
return
false
;
if
(
file
==
NULL
)
return
false
;
/*! */
/*! */
if
(
max
==
lim
-
1
)
C
opyToNextBlock
();
if
(
max
==
lim
-
1
)
c
opyToNextBlock
();
for
(
i
=
0
;
i
<
block_size
;
i
++
)
for
(
i
=
0
;
i
<
block_size
;
i
++
)
{
{
if
(
mem
[
i
]
->
count
<
0
)
if
(
mem
[
i
]
->
count
<
0
)
continue
;
continue
;
if
(
K
eyCompare
(
i
,
key
))
if
(
k
eyCompare
(
i
,
key
))
{
{
mem
[
i
]
->
count
=++
max
;
mem
[
i
]
->
count
=++
max
;
memset
(
K
eyPointer
(
i
),
0
,
k_size
);
memset
(
k
eyPointer
(
i
),
0
,
k_size
);
filewrite
(
i
);
filewrite
(
i
);
return
true
;
return
true
;
}
}
...
@@ -304,7 +304,8 @@ bool TableBlockStorage::DelRow(void* key)
...
@@ -304,7 +304,8 @@ bool TableBlockStorage::DelRow(void* key)
return
false
;
return
false
;
}
}
void
*
TableBlockStorage
::
FindKeyValue
(
void
*
key
,
void
*
val
)
/*! TODO: val, */
void
*
TableBlockStorage
::
findKeyValue
(
void
*
key
,
void
*
val
)
{
{
int
i
;
int
i
;
if
(
file
==
NULL
)
return
0
;
if
(
file
==
NULL
)
return
0
;
...
@@ -313,16 +314,16 @@ void* TableBlockStorage::FindKeyValue(void* key, void* val)
...
@@ -313,16 +314,16 @@ void* TableBlockStorage::FindKeyValue(void* key, void* val)
/*! >= 0, .. */
/*! >= 0, .. */
if
(
mem
[
i
]
->
count
<
0
)
if
(
mem
[
i
]
->
count
<
0
)
continue
;
continue
;
if
(
K
eyCompare
(
i
,
key
))
if
(
k
eyCompare
(
i
,
key
))
{
{
memcpy
(
val
,
V
alPointer
(
i
),
inf_size
);
memcpy
(
val
,
v
alPointer
(
i
),
inf_size
);
return
val
;
return
val
;
}
}
}
}
return
0
;
return
NULL
;
}
}
int
TableBlockStorage
::
G
etCurBlock
()
int
TableBlockStorage
::
g
etCurBlock
()
{
{
return
cur_block
;
return
cur_block
;
}
}
...
...
src/Various/TableStorage.cc
View file @
66eb4a98
...
@@ -110,10 +110,10 @@ TableStorage::~TableStorage()
...
@@ -110,10 +110,10 @@ TableStorage::~TableStorage()
fclose
(
file
);
fclose
(
file
);
}
}
int
TableStorage
::
A
ddRow
(
char
*
key
,
char
*
value
)
int
TableStorage
::
a
ddRow
(
char
*
key
,
char
*
value
)
{
{
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
k
,
j
;
int
i
,
k
,
j
,
st
;
if
(
file
!=
NULL
)
if
(
file
!=
NULL
)
{
{
if
(
head
==-
1
)
if
(
head
==-
1
)
...
@@ -151,19 +151,14 @@ int TableStorage::AddRow(char* key, char* value)
...
@@ -151,19 +151,14 @@ int TableStorage::AddRow(char* key, char* value)
fseek
(
file
,
seekpos
+
j
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fseek
(
file
,
seekpos
+
j
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
if
(
j
==
head
)
if
(
j
==
head
)
{
{
if
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
3
))
if
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
3
))
st
=
2
;
tbl
->
status
=
2
;
else
st
=
4
;
else
tbl
->
status
=
4
;
if
(
j
==
0
)
if
(
j
==
0
)
{
if
(
st
==
2
)
st
=
4
;
if
(
tbl
->
status
==
2
)
else
st
=
2
;
tbl
->
status
=
4
;
else
tbl
->
status
=
2
;
}
tbl
->
status
=
st
;
strcpy
(
tbl
->
key
,
key
);
strcpy
(
tbl
->
key
,
key
);
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
)
=*
(
value
+
k
);
*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
)
=*
(
value
+
k
);
...
@@ -184,25 +179,11 @@ int TableStorage::AddRow(char* key, char* value)
...
@@ -184,25 +179,11 @@ int TableStorage::AddRow(char* key, char* value)
if
(
head
>=
size
)
head
=
0
;
if
(
head
>=
size
)
head
=
0
;
return
0
;
return
0
;
}
}
/*for(i=0;i<size;i++)
{
fread(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
if(tbl->key[0]==0)
{
strcpy(tbl->key,key);
for(k=0;k<inf_size;k++)
*((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k);
fseek(file,seekpos+i*(sizeof(TableStorageElem)+inf_size),0);
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
return 0;
}
}*/
}
}
return
1
;
return
1
;
}
}
int
TableStorage
::
D
elRow
(
char
*
key
)
int
TableStorage
::
d
elRow
(
char
*
key
)
{
{
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
j
;
int
i
,
j
;
...
@@ -234,7 +215,7 @@ int TableStorage::DelRow(char* key)
...
@@ -234,7 +215,7 @@ int TableStorage::DelRow(char* key)
return
1
;
return
1
;
}
}
char
*
TableStorage
::
F
indKeyValue
(
char
*
key
,
char
*
val
)
char
*
TableStorage
::
f
indKeyValue
(
char
*
key
,
char
*
val
)
{
{
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
k
;
int
i
,
k
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment