blob: e2d19ed78b75c5228473ae25a32f7edee6f6a757 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "kpl.h"
static const kpl_interface object_string_interface = {
.gc_mark_object_fn = NULL,
.native_free_fn = NULL,
.log_fn = NULL
};
kpl_object_string *kpl_object_string_create(kpl_thread *thread, int32_t bytes_size) {
if (bytes_size < 0)
return NULL;
bytes_size++;
kpl_object_string *object_string = kpl_gc_new(thread, &object_string_interface,
sizeof(kpl_object_string) + sizeof(uint8_t) * bytes_size);
object_string->bytes_length = 0;
object_string->bytes_size = object_string->object_size - sizeof(kpl_object_string);
memset(object_string->bytes, '\0', object_string->bytes_size);
return object_string;
}
extern inline kpl_object_string *kpl_object_string_from_c_string(kpl_thread *thread, const char *c_string);
extern inline void kpl_object_string_destroy(kpl_thread *thread, kpl_object_string *object_string);
|