diff options
Diffstat (limited to 'sys/base/string/len.c')
-rw-r--r-- | sys/base/string/len.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/base/string/len.c b/sys/base/string/len.c new file mode 100644 index 0000000..5e42919 --- /dev/null +++ b/sys/base/string/len.c @@ -0,0 +1,17 @@ +#include "internal.h" + +// len returns the length of the string. +int +str·len(const string s) +{ + Hdr* h = (Hdr*)(s - sizeof(Hdr)); + return h->len; +} + +// cap returns the capacity of the string buffer. +int +str·cap(const string s) +{ + Hdr* h = (Hdr*)(s - sizeof(Hdr)); + return h->cap; +} |