#ifndef CT_STRING_H
#define CT_STRING_H

#include <stddef.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    const char *ptr;
    size_t length;
} ct_string_t;

static inline ct_string_t CT_STRING_FROM_PTR_LENGTH(const void *buf, size_t len) {
    ct_string_t s;
    s.ptr = (const char *)buf;
    s.length = len;
    return s;
}

static inline ct_string_t CT_STRING_FROM_CSTR(const char *str) {
    ct_string_t s;
    s.ptr = str;
    s.length = str ? strlen(str) : 0;
    return s;
}

#endif
