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
c8d9e7f4
Commit
c8d9e7f4
authored
May 29, 2010
by
Pieter Noordhuis
Browse files
change ziplistRepr to use the entry struct
parent
d593c488
Changes
1
Hide whitespace changes
Inline
Side-by-side
ziplist.c
View file @
c8d9e7f4
...
@@ -496,24 +496,22 @@ unsigned int ziplistSize(unsigned char *zl) {
...
@@ -496,24 +496,22 @@ unsigned int ziplistSize(unsigned char *zl) {
}
}
void
ziplistRepr
(
unsigned
char
*
zl
)
{
void
ziplistRepr
(
unsigned
char
*
zl
)
{
unsigned
char
*
p
,
encoding
;
unsigned
char
*
p
;
unsigned
int
prevrawlensize
,
prevrawlen
,
lensize
,
len
;
zlentry
entry
;
printf
(
"{total bytes %d} {length %u}
\n
"
,
ZIPLIST_BYTES
(
zl
),
ZIPLIST_LENGTH
(
zl
));
printf
(
"{total bytes %d} {length %u}
\n
"
,
ZIPLIST_BYTES
(
zl
),
ZIPLIST_LENGTH
(
zl
));
p
=
ziplistHead
(
zl
);
p
=
ziplistHead
(
zl
);
while
(
*
p
!=
ZIP_END
)
{
while
(
*
p
!=
ZIP_END
)
{
prevrawlen
=
zipDecodeLength
(
p
,
&
prevrawlensize
);
entry
=
zipEntry
(
p
);
len
=
zipDecodeLength
(
p
+
prevrawlensize
,
&
lensize
);
printf
(
"{offset %ld, header %u, payload %u} "
,
p
-
zl
,
entry
.
headersize
,
entry
.
len
);
printf
(
"{offset %ld, header %u, payload %u} "
,
p
-
zl
,
prevrawlensize
+
lensize
,
len
);
p
+=
entry
.
headersize
;
encoding
=
ZIP_ENCODING
(
p
+
prevrawlensize
);
if
(
entry
.
encoding
==
ZIP_ENC_RAW
)
{
p
+=
prevrawlensize
+
lensize
;
fwrite
(
p
,
entry
.
len
,
1
,
stdout
);
if
(
encoding
==
ZIP_ENC_RAW
)
{
fwrite
(
p
,
len
,
1
,
stdout
);
}
else
{
}
else
{
printf
(
"%lld"
,
zipLoadInteger
(
p
,
encoding
));
printf
(
"%lld"
,
zipLoadInteger
(
p
,
entry
.
encoding
));
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
p
+=
len
;
p
+=
entry
.
len
;
}
}
printf
(
"{end}
\n\n
"
);
printf
(
"{end}
\n\n
"
);
}
}
...
...
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