Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8ec08321
Commit
8ec08321
authored
Feb 27, 2010
by
antirez
Browse files
first zipmap fix of a long sequence in the days to come ;)
parent
eb46f4bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
zipmap.c
View file @
8ec08321
...
@@ -192,14 +192,14 @@ static unsigned long zipmapRequiredLength(unsigned int klen, unsigned int vlen)
...
@@ -192,14 +192,14 @@ static unsigned long zipmapRequiredLength(unsigned int klen, unsigned int vlen)
return
l
;
return
l
;
}
}
/* Return the total amo
n
ut used by a key (encoded length + payload) */
/* Return the total amou
n
t used by a key (encoded length + payload) */
static
unsigned
int
zipmapRawKeyLength
(
unsigned
char
*
p
)
{
static
unsigned
int
zipmapRawKeyLength
(
unsigned
char
*
p
)
{
unsigned
int
l
=
zipmapDecodeLength
(
p
);
unsigned
int
l
=
zipmapDecodeLength
(
p
);
return
zipmapEncodeLength
(
NULL
,
l
)
+
l
;
return
zipmapEncodeLength
(
NULL
,
l
)
+
l
;
}
}
/* Return the total amo
n
ut used by a value
/* Return the total amou
n
t used by a value
* (encoded length + single byte free count + payload) */
* (encoded length + single byte free count + payload) */
static
unsigned
int
zipmapRawValueLength
(
unsigned
char
*
p
)
{
static
unsigned
int
zipmapRawValueLength
(
unsigned
char
*
p
)
{
unsigned
int
l
=
zipmapDecodeLength
(
p
);
unsigned
int
l
=
zipmapDecodeLength
(
p
);
...
@@ -303,7 +303,7 @@ void zipmapRepr(unsigned char *p) {
...
@@ -303,7 +303,7 @@ void zipmapRepr(unsigned char *p) {
p
+=
zipmapEncodeLength
(
NULL
,
l
);
p
+=
zipmapEncodeLength
(
NULL
,
l
);
e
=
*
p
++
;
e
=
*
p
++
;
fwrite
(
p
,
l
,
1
,
stdout
);
fwrite
(
p
,
l
,
1
,
stdout
);
p
+=
l
;
p
+=
l
+
e
;
if
(
e
)
{
if
(
e
)
{
printf
(
"["
);
printf
(
"["
);
while
(
e
--
)
printf
(
"."
);
while
(
e
--
)
printf
(
"."
);
...
@@ -320,6 +320,7 @@ int main(void) {
...
@@ -320,6 +320,7 @@ int main(void) {
zm
=
zipmapNew
();
zm
=
zipmapNew
();
zm
=
zipmapSet
(
zm
,(
unsigned
char
*
)
"hello"
,
5
,
(
unsigned
char
*
)
"world!"
,
6
);
zm
=
zipmapSet
(
zm
,(
unsigned
char
*
)
"hello"
,
5
,
(
unsigned
char
*
)
"world!"
,
6
);
zm
=
zipmapSet
(
zm
,(
unsigned
char
*
)
"foo"
,
3
,
(
unsigned
char
*
)
"bar"
,
3
);
zm
=
zipmapSet
(
zm
,(
unsigned
char
*
)
"foo"
,
3
,
(
unsigned
char
*
)
"bar"
,
3
);
zm
=
zipmapSet
(
zm
,(
unsigned
char
*
)
"foo"
,
3
,
(
unsigned
char
*
)
"!"
,
1
);
zipmapRepr
(
zm
);
zipmapRepr
(
zm
);
return
0
;
return
0
;
}
}
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