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
f2377dd4
Commit
f2377dd4
authored
Aug 14, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CycleStorage minor fixes: code style and other...
parent
4e4a16d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
28 deletions
+27
-28
CycleStorage.cc
src/Various/CycleStorage.cc
+27
-28
No files found.
src/Various/CycleStorage.cc
View file @
f2377dd4
...
@@ -83,21 +83,19 @@ bool CycleStorage::findHead()
...
@@ -83,21 +83,19 @@ bool CycleStorage::findHead()
/*! - */
/*! - */
head
=
0
;
head
=
0
;
/*! , */
/*! , */
while
(
r
-
l
>
1
)
while
(
(
r
-
l
)
>
1
)
{
{
mid
=
(
l
+
r
)
/
2
;
mid
=
(
l
+
r
)
/
2
;
fseek
(
file
,
seekpos
+
mid
*
full_size
,
0
);
fseek
(
file
,
seekpos
+
mid
*
full_size
,
0
);
fread
(
jrn
,
full_size
,
1
,
file
);
fread
(
jrn
,
full_size
,
1
,
file
);
iter
++
;
iter
++
;
if
(
jrn
->
status
==
0
)
if
(
jrn
->
status
==
0
)
r
=
mid
;
r
=
mid
;
else
l
=
mid
;
else
}
l
=
mid
;
if
(
r
<
size
)
{
tail
=
r
-
1
;
}
}
else
tail
=
size
-
1
;
tail
=
(
r
<
size
)
?
(
r
-
1
)
:
(
size
-
1
);
}
}
else
else
{
{
...
@@ -105,7 +103,8 @@ bool CycleStorage::findHead()
...
@@ -105,7 +103,8 @@ bool CycleStorage::findHead()
/*! i 2-, 4-, 2-, 4-
/*! i 2-, 4-, 2-, 4-
*/
*/
i
=
jrn
->
status
-
jrn
->
status
%
2
;
i
=
jrn
->
status
-
jrn
->
status
%
2
;
if
(
i
==
2
)
j
=
4
;
else
j
=
2
;
j
=
(
i
==
2
)
?
4
:
2
;
while
((
jrn
->
status
!=
1
)
&&
(
jrn
->
status
!=
6
)
&&
(
r
-
l
>
1
))
while
((
jrn
->
status
!=
1
)
&&
(
jrn
->
status
!=
6
)
&&
(
r
-
l
>
1
))
{
{
mid
=
(
l
+
r
)
/
2
;
mid
=
(
l
+
r
)
/
2
;
...
@@ -123,17 +122,19 @@ bool CycleStorage::findHead()
...
@@ -123,17 +122,19 @@ bool CycleStorage::findHead()
}
}
else
else
{
{
delete
[]
jrn
;
return
false
;
return
false
;
}
}
}
}
if
(
r
<
size
)
head
=
r
;
head
=
(
r
<
size
)
?
r
:
(
size
-
1
)
;
else
head
=
size
-
1
;
/*! 1 , .. , */
/*! 1 , .. , */
tail
=
head
-
1
;
tail
=
head
-
1
;
if
(
tail
<
0
)
tail
=
size
-
1
;
if
(
tail
<
0
)
tail
=
size
-
1
;
}
}
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
...
@@ -242,7 +243,7 @@ bool CycleStorage::addRow(void* str)
...
@@ -242,7 +243,7 @@ bool CycleStorage::addRow(void* str)
filewrite
(
jrn
,
0
);
filewrite
(
jrn
,
0
);
head
=
0
;
head
=
0
;
tail
=
0
;
tail
=
0
;
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
if
(
head
==
tail
)
if
(
head
==
tail
)
...
@@ -250,7 +251,7 @@ bool CycleStorage::addRow(void* str)
...
@@ -250,7 +251,7 @@ bool CycleStorage::addRow(void* str)
jrn
->
status
=
2
;
jrn
->
status
=
2
;
filewrite
(
jrn
,
1
);
filewrite
(
jrn
,
1
);
tail
=
1
;
tail
=
1
;
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
fseek
(
file
,
seekpos
+
tail
*
full_size
,
0
);
fseek
(
file
,
seekpos
+
tail
*
full_size
,
0
);
...
@@ -259,8 +260,7 @@ bool CycleStorage::addRow(void* str)
...
@@ -259,8 +260,7 @@ bool CycleStorage::addRow(void* str)
/*! 2, 3 -> 2; 4, 5 -> 4
/*! 2, 3 -> 2; 4, 5 -> 4
*/
*/
if
((
jrn
->
status
==
2
)
||
(
jrn
->
status
==
3
))
i
=
2
;
i
=
((
jrn
->
status
==
2
)
||
(
jrn
->
status
==
3
))
?
2
:
4
;
else
i
=
4
;
/*! ,
/*! ,
2->4, 4->2
2->4, 4->2
...
@@ -270,10 +270,10 @@ bool CycleStorage::addRow(void* str)
...
@@ -270,10 +270,10 @@ bool CycleStorage::addRow(void* str)
{
{
fseek
(
file
,
seekpos
,
0
);
fseek
(
file
,
seekpos
,
0
);
tail
=
0
;
tail
=
0
;
if
(
i
==
2
)
i
=
4
;
i
=
(
i
==
2
)
?
4
:
2
;
else
i
=
2
;
}
}
else
tail
++
;
else
tail
++
;
fread
(
jrn
,
full_size
,
1
,
file
);
fread
(
jrn
,
full_size
,
1
,
file
);
memcpy
(
valPointer
(
jrn
),
str
,
inf_size
);
memcpy
(
valPointer
(
jrn
),
str
,
inf_size
);
if
(
jrn
->
status
==
0
)
if
(
jrn
->
status
==
0
)
...
@@ -297,7 +297,7 @@ bool CycleStorage::addRow(void* str)
...
@@ -297,7 +297,7 @@ bool CycleStorage::addRow(void* str)
else
jrn
->
status
=
1
;
else
jrn
->
status
=
1
;
filewrite
(
jrn
,
head
);
filewrite
(
jrn
,
head
);
}
}
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
...
@@ -317,19 +317,19 @@ bool CycleStorage::delRow(int row)
...
@@ -317,19 +317,19 @@ bool CycleStorage::delRow(int row)
{
{
jrn
->
status
=
6
;
jrn
->
status
=
6
;
filewrite
(
jrn
,
i
);
filewrite
(
jrn
,
i
);
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
if
(
jrn
->
status
==
2
)
j
=
3
;
if
(
jrn
->
status
==
2
)
j
=
3
;
else
if
(
jrn
->
status
==
4
)
j
=
5
;
else
if
(
jrn
->
status
==
4
)
j
=
5
;
else
else
{
{
delete
jrn
;
delete
[]
jrn
;
return
false
;
return
false
;
}
}
jrn
->
status
=
j
;
jrn
->
status
=
j
;
filewrite
(
jrn
,
i
);
filewrite
(
jrn
,
i
);
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
...
@@ -352,7 +352,7 @@ bool CycleStorage::delAllRows()
...
@@ -352,7 +352,7 @@ bool CycleStorage::delAllRows()
}
}
fflush
(
file
);
fflush
(
file
);
head
=
tail
=-
1
;
head
=
tail
=-
1
;
delete
jrn
;
delete
[]
jrn
;
return
true
;
return
true
;
}
}
...
@@ -374,14 +374,14 @@ void* CycleStorage::readRow(int num, void* str)
...
@@ -374,14 +374,14 @@ void* CycleStorage::readRow(int num, void* str)
if
((
jrn
->
status
==
1
)
||
(
jrn
->
status
==
2
)
||
(
jrn
->
status
==
4
))
if
((
jrn
->
status
==
1
)
||
(
jrn
->
status
==
2
)
||
(
jrn
->
status
==
4
))
{
{
memcpy
(
str
,
valPointer
(
jrn
),
inf_size
);
memcpy
(
str
,
valPointer
(
jrn
),
inf_size
);
delete
jrn
;
delete
[]
jrn
;
return
str
;
return
str
;
}
}
delete
jrn
;
delete
[]
jrn
;
return
NULL
;
return
NULL
;
}
}
int
CycleStorage
::
getIter
()
int
CycleStorage
::
getIter
()
{
{
return
iter
;
return
iter
;
}
}
\ No newline at end of file
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