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
739803c0
Commit
739803c0
authored
Mar 14, 2012
by
antirez
Browse files
sds.c: sdsAllocSize() function added.
parent
9555f8f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
739803c0
...
@@ -123,6 +123,12 @@ sds sdsRemoveFreeSpace(sds s) {
...
@@ -123,6 +123,12 @@ sds sdsRemoveFreeSpace(sds s) {
return
sh
->
buf
;
return
sh
->
buf
;
}
}
size_t
sdsAllocSize
(
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
return
sizeof
(
*
sh
)
+
sh
->
len
+
sh
->
free
+
1
;
}
/* Increment the sds length and decrements the left free space at the
/* Increment the sds length and decrements the left free space at the
* end of the string accordingly to 'incr'. Also set the null term
* end of the string accordingly to 'incr'. Also set the null term
* in the new end of the string.
* in the new end of the string.
...
...
src/sds.h
View file @
739803c0
...
@@ -94,5 +94,7 @@ sds sdsmapchars(sds s, char *from, char *to, size_t setlen);
...
@@ -94,5 +94,7 @@ sds sdsmapchars(sds s, char *from, char *to, size_t setlen);
/* Low level functions exposed to the user API */
/* Low level functions exposed to the user API */
sds
sdsMakeRoomFor
(
sds
s
,
size_t
addlen
);
sds
sdsMakeRoomFor
(
sds
s
,
size_t
addlen
);
void
sdsIncrLen
(
sds
s
,
int
incr
);
void
sdsIncrLen
(
sds
s
,
int
incr
);
sds
sdsRemoveFreeSpace
(
sds
s
);
size_t
sdsAllocSize
(
sds
s
);
#endif
#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