You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naka/include/str.h

32 lines
576 B

//! Better string handling
#ifndef _STR_H
#define _STR_H
#include <macros.h>
#include <ints.h>
#define STRF_OWNED AS(1ul << 5, int)
#define STRF_DERIVED AS(1ul << 6, int)
enum str_ownership {
STR_NULL = 0,
STR_OWNED = STRF_OWNED,
STR_OWNED_STATIC,
STR_OWNED_MALLOC,
STR_OWNED_STACK,
STR_DERIVED = STRF_DERIVED,
STR_DERIVED_STATIC,
STR_DERIVED_MALLOC,
STR_DERIVED_STACK,
};
typedef struct string str_t;
str_t* str_alloc(usize cap) _callconv(alloc);
char* str_new(const char* pIN cstr) _callconv(alloc);
void str_free(str_t* restrict str);
#endif /* _STR_H */