Inline sdslen and sdsavail (thanks to @bitbckt)

This commit is contained in:
Pieter Noordhuis
2011-04-19 23:10:45 +02:00
parent 9703b1b3dc
commit ded614f803
2 changed files with 11 additions and 11 deletions

View File

@ -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();