aboutsummaryrefslogtreecommitdiff
path: root/sys/base/string/len.c
blob: 5e42919e42835e6dc247332d3cc70a4ee88b3191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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;
}