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
c0997d17
Commit
c0997d17
authored
Jul 30, 2009
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug with fseek in TableBlockStorage and CycleStorage
parent
16eb3a8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
+14
-18
CycleStorage.cc
src/Various/CycleStorage.cc
+9
-10
TableBlockStorage.cc
src/Various/TableBlockStorage.cc
+5
-8
No files found.
src/Various/CycleStorage.cc
View file @
c0997d17
...
...
@@ -74,13 +74,10 @@ bool CycleStorage::Open(const char* name, int inf_sz, int sz, int seek)
if
(
file
==
NULL
)
return
false
;
seekpos
=
seek
;
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
CycleStorageAttr
*
csa
=
new
CycleStorageAttr
();
if
(
fseek
(
file
,
seekpos
,
0
)
==
0
)
fread
(
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
else
{
delete
csa
;
return
false
;
}
fread
(
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
if
((
csa
->
size
!=
((
sz
-
sizeof
(
CycleStorageAttr
))
/
(
sizeof
(
CycleStorageElem
)
+
inf_sz
)))
||
(
csa
->
inf_size
!=
inf_sz
)
||
(
csa
->
seekpos
!=
seek
))
{
...
...
@@ -173,19 +170,21 @@ bool CycleStorage::Create(const char* name, int inf_sz, int sz, int seek)
inf_size
=
inf_sz
;
full_size
=
sizeof
(
CycleStorageElem
)
+
inf_size
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
jrn
->
status
=
0
;
size
=
(
sz
-
sizeof
(
CycleStorageAttr
))
/
full_size
;
iter
=
0
;
seekpos
=
seek
;
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
jrn
->
status
=
0
;
CycleStorageAttr
*
csa
=
new
CycleStorageAttr
();
csa
->
inf_size
=
inf_size
;
csa
->
size
=
size
;
csa
->
seekpos
=
seekpos
;
fseek
(
file
,
seekpos
,
0
);
fwrite
(
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
fflush
(
file
);
seekpos
+=
sizeof
(
CycleStorageAttr
);
...
...
src/Various/TableBlockStorage.cc
View file @
c0997d17
...
...
@@ -122,14 +122,10 @@ bool TableBlockStorage::Open(const char* name, int key_sz, int inf_sz, int sz, i
if
(
file
==
NULL
)
return
false
;
seekpos
=
seek
;
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
StorageAttr
*
sa
=
new
StorageAttr
();
if
(
fseek
(
file
,
seekpos
,
0
)
==
0
)
fread
(
sa
,
sizeof
(
StorageAttr
),
1
,
file
);
else
{
delete
sa
;
return
false
;
}
fread
(
sa
,
sizeof
(
StorageAttr
),
1
,
file
);
full_size
=
sizeof
(
TableBlockStorageElem
)
+
key_sz
+
inf_sz
;
...
...
@@ -208,6 +204,8 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
size
=
block_size
*
block_num
;
max
=-
1
;
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
mem
=
new
TableBlockStorageElem
*
[
block_size
];
for
(
i
=
0
;
i
<
block_size
;
i
++
)
{
...
...
@@ -223,7 +221,6 @@ bool TableBlockStorage::Create(const char* name, int key_sz, int inf_sz, int sz,
sa
->
seekpos
=
seekpos
;
cur_block
=
0
;
fseek
(
file
,
seekpos
,
0
);
fwrite
(
sa
,
sizeof
(
StorageAttr
),
1
,
file
);
fflush
(
file
);
seekpos
+=
sizeof
(
StorageAttr
);
...
...
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