summaryrefslogtreecommitdiff
path: root/sds.h
diff options
context:
space:
mode:
Diffstat (limited to 'sds.h')
-rw-r--r--sds.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/sds.h b/sds.h
index eb41eb7..94f5871 100644
--- a/sds.h
+++ b/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(void);