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
Show 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,7 +418,7 @@ again:
...
@@ -418,7 +418,7 @@ again:
assert
(
keylen
+
datalen
+
leftover
<=
best
.
data_len
);
assert
(
keylen
+
datalen
+
leftover
<=
best
.
data_len
);
/* We need to mark non-free before we drop lock, otherwise
/* We need to mark non-free before we drop lock, otherwise
* coalesce() could try to merge it! */
* coalesce() could try to merge it! */
if
(
set_header
(
tdb
,
&
rec
,
keylen
,
datalen
,
if
(
set_
used_
header
(
tdb
,
&
rec
,
keylen
,
datalen
,
best
.
data_len
-
leftover
,
best
.
data_len
-
leftover
,
hashlow
)
!=
0
)
hashlow
)
!=
0
)
goto
unlock_err
;
goto
unlock_err
;
...
@@ -493,7 +493,7 @@ static tdb_off_t get_free(struct tdb_context *tdb,
...
@@ -493,7 +493,7 @@ static tdb_off_t get_free(struct tdb_context *tdb,
return
0
;
return
0
;
}
}
int
set_header
(
struct
tdb_context
*
tdb
,
int
set_
used_
header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
)
uint64_t
actuallen
,
unsigned
hashlow
)
...
...
ccan/tdb2/private.h
View file @
dfae76fd
...
@@ -382,7 +382,7 @@ int add_free_record(struct tdb_context *tdb,
...
@@ -382,7 +382,7 @@ int add_free_record(struct tdb_context *tdb,
tdb_off_t
off
,
tdb_len_t
len_with_header
);
tdb_off_t
off
,
tdb_len_t
len_with_header
);
/* Set up header for a used record. */
/* Set up header for a used record. */
int
set_header
(
struct
tdb_context
*
tdb
,
int
set_
used_
header
(
struct
tdb_context
*
tdb
,
struct
tdb_used_record
*
rec
,
struct
tdb_used_record
*
rec
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
keylen
,
uint64_t
datalen
,
uint64_t
actuallen
,
unsigned
hashlow
);
uint64_t
actuallen
,
unsigned
hashlow
);
...
...
ccan/tdb2/tdb.c
View file @
dfae76fd
...
@@ -111,7 +111,7 @@ static int tdb_new_database(struct tdb_context *tdb,
...
@@ -111,7 +111,7 @@ static int tdb_new_database(struct tdb_context *tdb,
/* Free is empty. */
/* Free is empty. */
newdb
.
hdr
.
free_list
=
offsetof
(
struct
new_database
,
flist
);
newdb
.
hdr
.
free_list
=
offsetof
(
struct
new_database
,
flist
);
memset
(
&
newdb
.
flist
,
0
,
sizeof
(
newdb
.
flist
));
memset
(
&
newdb
.
flist
,
0
,
sizeof
(
newdb
.
flist
));
set_header
(
NULL
,
&
newdb
.
flist
.
hdr
,
0
,
set_
used_
header
(
NULL
,
&
newdb
.
flist
.
hdr
,
0
,
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
1
);
sizeof
(
newdb
.
flist
)
-
sizeof
(
newdb
.
flist
.
hdr
),
1
);
...
@@ -364,7 +364,7 @@ static int update_rec_hdr(struct tdb_context *tdb,
...
@@ -364,7 +364,7 @@ static int update_rec_hdr(struct tdb_context *tdb,
{
{
uint64_t
dataroom
=
rec_data_length
(
rec
)
+
rec_extra_padding
(
rec
);
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
-
1
;
return
tdb_write_convert
(
tdb
,
off
,
rec
,
sizeof
(
*
rec
));
return
tdb_write_convert
(
tdb
,
off
,
rec
,
sizeof
(
*
rec
));
...
...
ccan/tdb2/test/layout.c
View file @
dfae76fd
...
@@ -97,7 +97,7 @@ static void set_data_record(void *mem, struct tdb_context *tdb,
...
@@ -97,7 +97,7 @@ static void set_data_record(void *mem, struct tdb_context *tdb,
{
{
struct
tdb_used_record
*
u
=
mem
;
struct
tdb_used_record
*
u
=
mem
;
set_header
(
tdb
,
u
,
used
->
key
.
dsize
,
used
->
data
.
dsize
,
set_
used_
header
(
tdb
,
u
,
used
->
key
.
dsize
,
used
->
data
.
dsize
,
used
->
key
.
dsize
+
used
->
data
.
dsize
+
used
->
extra
,
used
->
key
.
dsize
+
used
->
data
.
dsize
+
used
->
extra
,
tdb_hash
(
tdb
,
used
->
key
.
dptr
,
used
->
key
.
dsize
));
tdb_hash
(
tdb
,
used
->
key
.
dptr
,
used
->
key
.
dsize
));
memcpy
(
u
+
1
,
used
->
key
.
dptr
,
used
->
key
.
dsize
);
memcpy
(
u
+
1
,
used
->
key
.
dptr
,
used
->
key
.
dsize
);
...
@@ -111,7 +111,7 @@ static void set_hashtable(void *mem, struct tdb_context *tdb,
...
@@ -111,7 +111,7 @@ static void set_hashtable(void *mem, struct tdb_context *tdb,
struct
tdb_used_record
*
u
=
mem
;
struct
tdb_used_record
*
u
=
mem
;
tdb_len_t
len
=
sizeof
(
tdb_off_t
)
<<
TDB_SUBLEVEL_HASH_BITS
;
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
);
memset
(
u
+
1
,
0
,
len
);
}
}
...
@@ -121,7 +121,7 @@ static void set_freelist(void *mem, struct tdb_context *tdb,
...
@@ -121,7 +121,7 @@ static void set_freelist(void *mem, struct tdb_context *tdb,
{
{
struct
tdb_freelist
*
flist
=
mem
;
struct
tdb_freelist
*
flist
=
mem
;
memset
(
flist
,
0
,
sizeof
(
*
flist
));
memset
(
flist
,
0
,
sizeof
(
*
flist
));
set_header
(
tdb
,
&
flist
->
hdr
,
0
,
set_
used_
header
(
tdb
,
&
flist
->
hdr
,
0
,
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
1
);
sizeof
(
*
flist
)
-
sizeof
(
flist
->
hdr
),
1
);
...
...
ccan/tdb2/test/run-001-encode.c
View file @
dfae76fd
...
@@ -18,12 +18,14 @@ int main(int argc, char *argv[])
...
@@ -18,12 +18,14 @@ int main(int argc, char *argv[])
/* We should be able to encode any data value. */
/* We should be able to encode any data value. */
for
(
i
=
0
;
i
<
64
;
i
++
)
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. */
/* And any key and data with < 64 bits between them. */
for
(
i
=
0
;
i
<
32
;
i
++
)
{
for
(
i
=
0
;
i
<
32
;
i
++
)
{
tdb_len_t
dlen
=
1ULL
>>
(
63
-
i
),
klen
=
1ULL
<<
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. */
/* We should neatly encode all values. */
...
@@ -32,7 +34,7 @@ int main(int argc, char *argv[])
...
@@ -32,7 +34,7 @@ int main(int argc, char *argv[])
uint64_t
klen
=
1ULL
<<
(
i
<
16
?
i
:
15
);
uint64_t
klen
=
1ULL
<<
(
i
<
16
?
i
:
15
);
uint64_t
dlen
=
1ULL
<<
i
;
uint64_t
dlen
=
1ULL
<<
i
;
uint64_t
xlen
=
1ULL
<<
(
i
<
32
?
i
:
31
);
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
);
==
0
);
ok1
(
rec_key_length
(
&
rec
)
==
klen
);
ok1
(
rec_key_length
(
&
rec
)
==
klen
);
ok1
(
rec_data_length
(
&
rec
)
==
dlen
);
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