mirror of
https://github.com/fluencelabs/redis
synced 2025-06-25 06:51:32 +00:00
Inline sdslen and sdsavail (thanks to @bitbckt)
This commit is contained in:
10
src/sds.h
10
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();
|
||||
|
Reference in New Issue
Block a user