blob: 8c88825fc72adb4428787bb305d30fe39a57a6c6 (
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
25
26
27
28
29
|
/*
* KPL UTF-8 string and character methods
*/
#pragma once
/*
* Create new string
*/
kpl_object_string *kpl_object_string_create(kpl_thread *thread, int32_t bytes_size);
/*
* Create a string from a c string
* Copies the c string
*/
inline kpl_object_string *kpl_object_string_from_c_string(kpl_thread *thread, const char *c_string) {
int32_t bytes_size = strlen(c_string);
kpl_object_string *object_string = kpl_object_string_create(thread, bytes_size);
object_string->bytes_length = bytes_size;
memcpy(object_string->bytes, c_string, bytes_size);
return object_string;
}
/*
* Return string to gc before sweep
*/
inline void kpl_object_string_destroy(kpl_thread *thread, kpl_object_string *object_string) {
kpl_gc_delete(thread, (kpl_object*) object_string);
}
|