snapkitty
compilers
c
python
nasm
File size: 459 Bytes
9abace2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef SOVEREIGN_STRINGS_H
#define SOVEREIGN_STRINGS_H

#include <stddef.h>
#include <stdbool.h>

typedef struct Str {
    const char *ptr;
    size_t      len;
} Str;

void strings_init(void);
void strings_shutdown(void);

Str  str_intern(const char *cstr);
Str  str_intern_len(const char *data, size_t len);
bool str_eq(Str a, Str b);

#define STR_FMT "%.*s"
#define STR_ARG(s) (int)(s).len, (s).ptr

#endif /* SOVEREIGN_STRINGS_H */