diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-04-19 22:59:26 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-04-19 22:59:26 +0200 |
commit | cd7063e85b3f7b32f7e37585615d4180a1188cba (patch) | |
tree | 4aa3d49790379fe181fd37a69f7a8da6bacf2698 /sds.h | |
parent | d5b18b5d2878255440b9f8f73f4613190d3376b0 (diff) |
Inline sdslen and sdsavail (thanks to @bitbckt)
Diffstat (limited to 'sds.h')
-rw-r--r-- | 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(void); |