summaryrefslogtreecommitdiff
path: root/src/sds.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-03-14 14:58:26 +0100
committerantirez <antirez@gmail.com>2012-03-14 14:58:26 +0100
commit739803c06403481f32534a4ab5f5735fa1b52e6f (patch)
tree664f91621103498ff84a405bb30f64a29bc7289f /src/sds.c
parent9555f8f21b9f1780de307c19da268ef63f7c2ae9 (diff)
downloadredis-739803c06403481f32534a4ab5f5735fa1b52e6f.tar.gz
sds.c: sdsAllocSize() function added.
Diffstat (limited to 'src/sds.c')
-rw-r--r--src/sds.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sds.c b/src/sds.c
index 82d12e232..bc6aa6b2f 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -123,6 +123,12 @@ sds sdsRemoveFreeSpace(sds s) {
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
* end of the string accordingly to 'incr'. Also set the null term
* in the new end of the string.