Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
dfae76fd
Commit
dfae76fd
authored
Nov 23, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb2: rename set_header to the more appropriate set_used_header.
parent
076c398e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
25 deletions
+27
-25
ccan/tdb2/free.c
ccan/tdb2/free.c
+7
-7
ccan/tdb2/private.h
ccan/tdb2/private.h
+4
-4
ccan/tdb2/tdb.c
ccan/tdb2/tdb.c
+4
-4
ccan/tdb2/test/layout.c
ccan/tdb2/test/layout.c
+7
-7
ccan/tdb2/test/run-001-encode.c
ccan/tdb2/test/run-001-encode.c
+5
-3
No files found.
ccan/tdb2/free.c
View file @
dfae76fd
...
...
@@ -418,9 +418,9 @@ again:
assert
(
keylen
+
datalen
+
leftover
<=
best
.
data_len
);
/* We need to mark non-free before we drop lock, otherwise
* coalesce() could try to merge it! */
if
(
set_header
(
tdb
,
&
rec
,
keylen
,
datalen
,
best
.
data_len
-
leftover
,
hashlow
)
!=
0
)
if
(
set_
used_
header
(
tdb
,
&
rec
,
keylen
,
datalen
,
best
.
data_len
-
leftover
,
hashlow
)
!=
0
)
goto
unlock_err
;
if
(
tdb_write_convert
(
tdb
,
best_off
,
&
rec
,
sizeof
(
rec
))
!=
0
)
...
...
@@ -493,10 +493,10 @@ static tdb_off_t get_free(struct tdb_context *tdb,
return
0
;
}
int
set_header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
)
int
set_
used_
header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
)
{
uint64_t
keybits
=
(
fls64
(
keylen
)
+
1
)
/
2
;
...
...
ccan/tdb2/private.h
View file @
dfae76fd
...
...
@@ -382,10 +382,10 @@ int add_free_record(struct tdb_context *tdb,
tdb_off_t
off
,
tdb_len_t
len_with_header
);
/* Set up header for a used record. */
int
set_header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
);
int
set_
used_
header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
);
/* Used by tdb_check to verify. */
unsigned
int
size_to_bucket
(
tdb_len_t
data_len
);
...
...
ccan/tdb2/tdb.c
View file @
dfae76fd
...
...
@@ -111,9 +111,9 @@ static int tdb_new_database(struct tdb_context *tdb,
/* Free is empty. */
newdb
.
hdr
.
free_list
=
offsetof
(
struct
new_database
,
flist
);
memset
(
&
newdb
.
flist
,
0
,
sizeof
(
newdb
.
flist
));
set_header
(
NULL
,
&
newdb
.
flist
.
hdr
,
0
,
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
1
);
set_
used_
header
(
NULL
,
&
newdb
.
flist
.
hdr
,
0
,
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
1
);
/* Magic food */
memset
(
newdb
.
hdr
.
magic_food
,
0
,
sizeof
(
newdb
.
hdr
.
magic_food
));
...
...
@@ -364,7 +364,7 @@ static int update_rec_hdr(struct tdb_context *tdb,
{
uint64_t
dataroom
=
rec_data_length
(
rec
)
+
rec_extra_padding
(
rec
);
if
(
set_header
(
tdb
,
rec
,
keylen
,
datalen
,
keylen
+
dataroom
,
h
))
if
(
set_
used_
header
(
tdb
,
rec
,
keylen
,
datalen
,
keylen
+
dataroom
,
h
))
return
-
1
;
return
tdb_write_convert
(
tdb
,
off
,
rec
,
sizeof
(
*
rec
));
...
...
ccan/tdb2/test/layout.c
View file @
dfae76fd
...
...
@@ -97,9 +97,9 @@ static void set_data_record(void *mem, struct tdb_context *tdb,
{
struct
tdb_used_record
*
u
=
mem
;
set_header
(
tdb
,
u
,
used
->
key
.
dsize
,
used
->
data
.
dsize
,
used
->
key
.
dsize
+
used
->
data
.
dsize
+
used
->
extra
,
tdb_hash
(
tdb
,
used
->
key
.
dptr
,
used
->
key
.
dsize
));
set_
used_
header
(
tdb
,
u
,
used
->
key
.
dsize
,
used
->
data
.
dsize
,
used
->
key
.
dsize
+
used
->
data
.
dsize
+
used
->
extra
,
tdb_hash
(
tdb
,
used
->
key
.
dptr
,
used
->
key
.
dsize
));
memcpy
(
u
+
1
,
used
->
key
.
dptr
,
used
->
key
.
dsize
);
memcpy
((
char
*
)(
u
+
1
)
+
used
->
key
.
dsize
,
used
->
data
.
dptr
,
used
->
data
.
dsize
);
...
...
@@ -111,7 +111,7 @@ static void set_hashtable(void *mem, struct tdb_context *tdb,
struct
tdb_used_record
*
u
=
mem
;
tdb_len_t
len
=
sizeof
(
tdb_off_t
)
<<
TDB_SUBLEVEL_HASH_BITS
;
set_header
(
tdb
,
u
,
0
,
len
,
len
+
htable
->
extra
,
0
);
set_
used_
header
(
tdb
,
u
,
0
,
len
,
len
+
htable
->
extra
,
0
);
memset
(
u
+
1
,
0
,
len
);
}
...
...
@@ -121,9 +121,9 @@ static void set_freelist(void *mem, struct tdb_context *tdb,
{
struct
tdb_freelist
*
flist
=
mem
;
memset
(
flist
,
0
,
sizeof
(
*
flist
));
set_header
(
tdb
,
&
flist
->
hdr
,
0
,
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
1
);
set_
used_
header
(
tdb
,
&
flist
->
hdr
,
0
,
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
1
);
if
(
last_flist
)
{
flist
=
(
struct
tdb_freelist
*
)((
char
*
)
hdr
+
last_flist
);
...
...
ccan/tdb2/test/run-001-encode.c
View file @
dfae76fd
...
...
@@ -18,12 +18,14 @@ int main(int argc, char *argv[])
/* We should be able to encode any data value. */
for
(
i
=
0
;
i
<
64
;
i
++
)
ok1
(
set_header
(
&
tdb
,
&
rec
,
0
,
1ULL
<<
i
,
1ULL
<<
i
,
0
)
==
0
);
ok1
(
set_used_header
(
&
tdb
,
&
rec
,
0
,
1ULL
<<
i
,
1ULL
<<
i
,
0
)
==
0
);
/* And any key and data with < 64 bits between them. */
for
(
i
=
0
;
i
<
32
;
i
++
)
{
tdb_len_t
dlen
=
1ULL
>>
(
63
-
i
),
klen
=
1ULL
<<
i
;
ok1
(
set_header
(
&
tdb
,
&
rec
,
klen
,
dlen
,
klen
+
dlen
,
0
)
==
0
);
ok1
(
set_used_header
(
&
tdb
,
&
rec
,
klen
,
dlen
,
klen
+
dlen
,
0
)
==
0
);
}
/* We should neatly encode all values. */
...
...
@@ -32,7 +34,7 @@ int main(int argc, char *argv[])
uint64_t
klen
=
1ULL
<<
(
i
<
16
?
i
:
15
);
uint64_t
dlen
=
1ULL
<<
i
;
uint64_t
xlen
=
1ULL
<<
(
i
<
32
?
i
:
31
);
ok1
(
set_
header
(
&
tdb
,
&
rec
,
klen
,
dlen
,
klen
+
dlen
+
xlen
,
h
)
ok1
(
set_
used_header
(
&
tdb
,
&
rec
,
klen
,
dlen
,
klen
+
dlen
+
xlen
,
h
)
==
0
);
ok1
(
rec_key_length
(
&
rec
)
==
klen
);
ok1
(
rec_data_length
(
&
rec
)
==
dlen
);
...
...
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