]> git.saurik.com Git - redis.git/blobdiff - src/sds.c
ziplist.c: added comments about the new 24 bit encoding.
[redis.git] / src / sds.c
index 82d12e232a4f774477046be8e909ae439cafda4b..bc6aa6b2f25cc8988b405782a3e25d50e08ea704 100644 (file)
--- 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.