Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
06278a67
Commit
06278a67
authored
Apr 01, 2010
by
Pieter Noordhuis
Browse files
use function to determine length of a single entry
parent
38192079
Changes
1
Hide whitespace changes
Inline
Side-by-side
zipmap.c
View file @
06278a67
...
@@ -201,7 +201,6 @@ static unsigned int zipmapRawValueLength(unsigned char *p) {
...
@@ -201,7 +201,6 @@ static unsigned int zipmapRawValueLength(unsigned char *p) {
* free space if any). */
* free space if any). */
static
unsigned
int
zipmapRawEntryLength
(
unsigned
char
*
p
)
{
static
unsigned
int
zipmapRawEntryLength
(
unsigned
char
*
p
)
{
unsigned
int
l
=
zipmapRawKeyLength
(
p
);
unsigned
int
l
=
zipmapRawKeyLength
(
p
);
return
l
+
zipmapRawValueLength
(
p
+
l
);
return
l
+
zipmapRawValueLength
(
p
+
l
);
}
}
...
@@ -232,14 +231,10 @@ unsigned char *zipmapSet(unsigned char *zm, unsigned char *key, unsigned int kle
...
@@ -232,14 +231,10 @@ unsigned char *zipmapSet(unsigned char *zm, unsigned char *key, unsigned int kle
/* Increase zipmap length (this is an insert) */
/* Increase zipmap length (this is an insert) */
if
(
zm
[
0
]
<
ZIPMAP_BIGLEN
)
zm
[
0
]
++
;
if
(
zm
[
0
]
<
ZIPMAP_BIGLEN
)
zm
[
0
]
++
;
}
else
{
}
else
{
unsigned
char
*
b
=
p
;
/* Key found. Is there enough space for the new value? */
/* Key found. Is there enough space for the new value? */
/* Compute the total length: */
/* Compute the total length: */
if
(
update
)
*
update
=
1
;
if
(
update
)
*
update
=
1
;
freelen
=
zipmapRawKeyLength
(
b
);
freelen
=
zipmapRawEntryLength
(
p
);
b
+=
freelen
;
freelen
+=
zipmapRawValueLength
(
b
);
if
(
freelen
<
reqlen
)
{
if
(
freelen
<
reqlen
)
{
/* Move remaining entries to the current position, so this
/* Move remaining entries to the current position, so this
* pair can be appended. Note: the +1 in memmove is caused
* pair can be appended. Note: the +1 in memmove is caused
...
...
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