28 lines
509 B
C
28 lines
509 B
C
#include "str8.h"
|
|
#include <string.h>
|
|
|
|
Str8 wapp_str8_lit(char *str) {
|
|
if (!str) {
|
|
return (Str8){.capacity = 0, .size = 0, .buf = (u8 *)""};
|
|
}
|
|
|
|
u64 size = strlen(str);
|
|
return (Str8){.capacity = size, .size = size, .buf = (u8 *)str};
|
|
}
|
|
|
|
char wapp_str8_get(const Str8 *str, u64 index) {
|
|
if (index >= str->size) {
|
|
return '\0';
|
|
}
|
|
|
|
return (char)(str->buf[index]);
|
|
}
|
|
|
|
void wapp_str8_set(Str8 *str, u64 index, char c) {
|
|
if (index >= str->size) {
|
|
return;
|
|
}
|
|
|
|
str->buf[index] = (u8)c;
|
|
}
|