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
b53f05b2
Commit
b53f05b2
authored
Aug 12, 2009
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set correct size of journal in CycleStorage
parent
231f2434
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
21 deletions
+11
-21
Storages.h
include/Storages.h
+1
-1
CycleStorage.cc
src/Various/CycleStorage.cc
+10
-20
No files found.
include/Storages.h
View file @
b53f05b2
...
...
@@ -178,7 +178,7 @@ class CycleStorage
int
full_size
;
void
filewrite
(
CycleStorageElem
*
jrn
,
int
seek
,
bool
needflush
=
true
);
void
*
valPointer
(
void
*
pnt
);
void
findHead
();
bool
findHead
();
};
#endif
src/Various/CycleStorage.cc
View file @
b53f05b2
...
...
@@ -66,7 +66,7 @@ void CycleStorage::filewrite(CycleStorageElem* jrn,int seek,bool needflush)
( 2 - 4 , ), 3 - 2, 5 - 4, 6 - 1.
|
*/
void
CycleStorage
::
findHead
()
bool
CycleStorage
::
findHead
()
{
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
int
l
=-
1
,
r
=
size
,
mid
;
...
...
@@ -116,11 +116,13 @@ void CycleStorage::findHead()
l
=
mid
;
else
if
((
jrn
->
status
==
j
)
||
(
jrn
->
status
==
j
+
1
))
r
=
mid
;
else
else
if
((
jrn
->
status
==
1
)
||
(
jrn
->
status
==
6
))
{
r
=
mid
;
break
;
}
else
return
false
;
}
if
(
r
<
size
)
head
=
r
;
...
...
@@ -130,6 +132,7 @@ void CycleStorage::findHead()
if
(
tail
<
0
)
tail
=
size
-
1
;
}
delete
jrn
;
return
true
;
}
bool
CycleStorage
::
open
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
)
...
...
@@ -148,19 +151,17 @@ bool CycleStorage::open(const char* name, int inf_sz, int inf_count, int seek)
CycleStorageAttr
csa
;
fread
(
&
csa
,
sizeof
(
csa
),
1
,
file
);
int
sz
=
inf_sz
*
inf_count
;
/*! */
if
((
csa
.
size
!=
(
int
)((
sz
-
sizeof
(
csa
))
/
(
sizeof
(
CycleStorageElem
)
+
inf_sz
))
)
||
(
csa
.
inf_size
!=
inf_sz
)
||
(
csa
.
seekpos
!=
seek
))
if
((
csa
.
size
!=
inf_count
)
||
(
csa
.
inf_size
!=
inf_sz
)
||
(
csa
.
seekpos
!=
seek
))
return
false
;
inf_size
=
inf_sz
;
full_size
=
sizeof
(
CycleStorageElem
)
+
inf_size
;
size
=
(
sz
-
sizeof
(
csa
))
/
full_size
;
size
=
inf_count
;
seekpos
=
seek
;
seekpos
+=
sizeof
(
CycleStorageAttr
);
findHead
();
if
(
!
findHead
())
return
false
;
return
true
;
}
...
...
@@ -176,12 +177,11 @@ bool CycleStorage::create(const char* name, int inf_sz, int inf_count, int seek)
file
=
fopen
(
name
,
"r+"
);
}
int
sz
=
inf_sz
*
inf_count
;
inf_size
=
inf_sz
;
full_size
=
sizeof
(
CycleStorageElem
)
+
inf_size
;
size
=
(
sz
-
sizeof
(
CycleStorageAttr
))
/
full_size
;
size
=
inf_count
;
iter
=
0
;
seekpos
=
seek
;
...
...
@@ -207,16 +207,6 @@ bool CycleStorage::create(const char* name, int inf_sz, int inf_count, int seek)
filewrite
(
jrn
,
i
,
false
);
}
fflush
(
file
);
/*! , , */
int
emp
=
sz
-
size
*
full_size
-
sizeof
(
CycleStorageAttr
);
if
(
emp
>
0
)
{
char
*
empty
=
new
char
[
emp
];
fwrite
(
empty
,
emp
,
1
,
file
);
fflush
(
file
);
delete
empty
;
}
head
=
tail
=-
1
;
delete
jrn
;
...
...
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