X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/726a39c15ff5d89f0d44a32cca8869cf0589f929..16cd4acdeed9f38802606bfad206b632d4cb5039:/src/sds.h diff --git a/src/sds.h b/src/sds.h index 6a317868..ea43f868 100644 --- a/src/sds.h +++ b/src/sds.h @@ -42,6 +42,16 @@ struct sdshdr { char buf[]; }; +static inline size_t sdslen(const sds s) { + struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr))); + return sh->len; +} + +static inline size_t sdsavail(const sds s) { + struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr))); + return sh->free; +} + sds sdsnewlen(const void *init, size_t initlen); sds sdsnew(const char *init); sds sdsempty();