diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-04-19 23:10:45 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-05-05 16:25:48 +0200 |
commit | ded614f803f56ad979da76485e74732ecdcc57fd (patch) | |
tree | f3c5d43491f85baa5b336398d539f461c88652f4 /src/sds.h | |
parent | 9703b1b3dc59aa76a314373fff748e26bdd0466f (diff) | |
download | redis-ded614f803f56ad979da76485e74732ecdcc57fd.tar.gz |
Inline sdslen and sdsavail (thanks to @bitbckt)
Diffstat (limited to 'src/sds.h')
-rw-r--r-- | src/sds.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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(); |