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
dbaa41c6
Commit
dbaa41c6
authored
May 30, 2010
by
Pieter Noordhuis
Browse files
the tail offset must be an integer pointer to hold a 32-bit offset
parent
d2ee16ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
ziplist.c
View file @
dbaa41c6
...
...
@@ -45,7 +45,7 @@
/* Utility macros */
#define ZIPLIST_BYTES(zl) (*((unsigned int*)(zl)))
#define ZIPLIST_TAIL_OFFSET(zl) (*((zl)+sizeof(unsigned int)))
#define ZIPLIST_TAIL_OFFSET(zl) (*((
unsigned int*)((
zl)+sizeof(unsigned int)))
)
#define ZIPLIST_LENGTH(zl) (*((zl)+2*sizeof(unsigned int)))
#define ZIPLIST_HEADER_SIZE (2*sizeof(unsigned int)+1)
#define ZIPLIST_ENTRY_HEAD(zl) ((zl)+ZIPLIST_HEADER_SIZE)
...
...
@@ -853,6 +853,27 @@ int main(int argc, char **argv) {
ziplistRepr
(
zl
);
}
printf
(
"Create long list and check indices:
\n
"
);
{
zl
=
ziplistNew
();
char
buf
[
32
];
int
i
,
len
;
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
len
=
sprintf
(
buf
,
"%d"
,
i
);
zl
=
ziplistPush
(
zl
,
buf
,
len
,
ZIPLIST_TAIL
);
}
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
p
=
ziplistIndex
(
zl
,
i
);
assert
(
ziplistGet
(
p
,
NULL
,
NULL
,
&
value
));
assert
(
i
==
value
);
p
=
ziplistIndex
(
zl
,
-
i
-
1
);
assert
(
ziplistGet
(
p
,
NULL
,
NULL
,
&
value
));
assert
(
999
-
i
==
value
);
}
printf
(
"SUCCESS
\n\n
"
);
}
printf
(
"Compare strings with ziplist entries:
\n
"
);
{
zl
=
createList
();
...
...
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