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
1c53928f
Commit
1c53928f
authored
Feb 17, 2011
by
Pieter Noordhuis
Committed by
antirez
Apr 20, 2011
Browse files
Functions to get size of specially encoded value in bytes
parent
660a0cdf
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/intset.c
View file @
1c53928f
...
...
@@ -222,6 +222,11 @@ uint32_t intsetLen(intset *is) {
return
is
->
length
;
}
/* Return intset size in bytes. */
size_t
intsetSize
(
intset
*
is
)
{
return
sizeof
(
intset
)
+
is
->
length
*
is
->
encoding
;
}
#ifdef INTSET_TEST_MAIN
#include <sys/time.h>
...
...
src/intset.h
View file @
1c53928f
...
...
@@ -15,5 +15,6 @@ uint8_t intsetFind(intset *is, int64_t value);
int64_t
intsetRandom
(
intset
*
is
);
uint8_t
intsetGet
(
intset
*
is
,
uint32_t
pos
,
int64_t
*
value
);
uint32_t
intsetLen
(
intset
*
is
);
size_t
intsetSize
(
intset
*
is
);
#endif // __INTSET_H
src/ziplist.c
View file @
1c53928f
...
...
@@ -732,8 +732,8 @@ unsigned int ziplistLen(unsigned char *zl) {
return
len
;
}
/* Return size in bytes
of ziplist
. */
unsigned
in
t
ziplistSize
(
unsigned
char
*
zl
)
{
/* Return
ziplist
size in bytes. */
size_
t
ziplistSize
(
unsigned
char
*
zl
)
{
return
ZIPLIST_BYTES
(
zl
);
}
...
...
src/ziplist.h
View file @
1c53928f
...
...
@@ -12,4 +12,4 @@ unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p);
unsigned
char
*
ziplistDeleteRange
(
unsigned
char
*
zl
,
unsigned
int
index
,
unsigned
int
num
);
unsigned
int
ziplistCompare
(
unsigned
char
*
p
,
unsigned
char
*
s
,
unsigned
int
slen
);
unsigned
int
ziplistLen
(
unsigned
char
*
zl
);
unsigned
in
t
ziplistSize
(
unsigned
char
*
zl
);
size_
t
ziplistSize
(
unsigned
char
*
zl
);
src/zipmap.c
View file @
1c53928f
...
...
@@ -144,7 +144,7 @@ static unsigned char *zipmapLookupRaw(unsigned char *zm, unsigned char *key, uns
/* Match or skip the key */
l
=
zipmapDecodeLength
(
p
);
llen
=
zipmapEncodeLength
(
NULL
,
l
);
if
(
k
==
NULL
&&
l
==
klen
&&
!
memcmp
(
p
+
llen
,
key
,
l
))
{
if
(
key
!=
NULL
&&
k
==
NULL
&&
l
==
klen
&&
!
memcmp
(
p
+
llen
,
key
,
l
))
{
/* Only return when the user doesn't care
* for the total length of the zipmap. */
if
(
totlen
!=
NULL
)
{
...
...
@@ -360,6 +360,13 @@ unsigned int zipmapLen(unsigned char *zm) {
return
len
;
}
/* Return zipmap size in bytes. */
size_t
zipmapSize
(
unsigned
char
*
zm
)
{
unsigned
int
totlen
;
zipmapLookupRaw
(
zm
,
NULL
,
0
,
&
totlen
);
return
totlen
;
}
#ifdef ZIPMAP_TEST_MAIN
void
zipmapRepr
(
unsigned
char
*
p
)
{
...
...
src/zipmap.h
View file @
1c53928f
...
...
@@ -43,5 +43,6 @@ unsigned char *zipmapNext(unsigned char *zm, unsigned char **key, unsigned int *
int
zipmapGet
(
unsigned
char
*
zm
,
unsigned
char
*
key
,
unsigned
int
klen
,
unsigned
char
**
value
,
unsigned
int
*
vlen
);
int
zipmapExists
(
unsigned
char
*
zm
,
unsigned
char
*
key
,
unsigned
int
klen
);
unsigned
int
zipmapLen
(
unsigned
char
*
zm
);
size_t
zipmapSize
(
unsigned
char
*
zm
);
#endif
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