mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Compute number of code points and byte len
This commit is contained in:
parent
13254d06f0
commit
6c4dd4b740
1 changed files with 4 additions and 1 deletions
|
@ -952,7 +952,8 @@
|
||||||
" object s = NULL;
|
" object s = NULL;
|
||||||
Cyc_check_int(data, count);
|
Cyc_check_int(data, count);
|
||||||
char c = obj_obj2char(fill);
|
char c = obj_obj2char(fill);
|
||||||
int len = obj_obj2int(count);
|
int num_cp = obj_obj2int(count);
|
||||||
|
int len = num_cp * uint32_num_bytes(c);
|
||||||
if (len >= MAX_STACK_OBJ) {
|
if (len >= MAX_STACK_OBJ) {
|
||||||
int heap_grown;
|
int heap_grown;
|
||||||
s = gc_alloc(((gc_thread_data *)data)->heap,
|
s = gc_alloc(((gc_thread_data *)data)->heap,
|
||||||
|
@ -964,6 +965,7 @@
|
||||||
((string_type *) s)->hdr.grayed = 0;
|
((string_type *) s)->hdr.grayed = 0;
|
||||||
((string_type *) s)->tag = string_tag;
|
((string_type *) s)->tag = string_tag;
|
||||||
((string_type *) s)->len = len;
|
((string_type *) s)->len = len;
|
||||||
|
((string_type *) s)->num_cp = num_cp;
|
||||||
((string_type *) s)->str = (((char *)s) + sizeof(string_type));
|
((string_type *) s)->str = (((char *)s) + sizeof(string_type));
|
||||||
} else {
|
} else {
|
||||||
s = alloca(sizeof(string_type));
|
s = alloca(sizeof(string_type));
|
||||||
|
@ -971,6 +973,7 @@
|
||||||
((string_type *)s)->hdr.grayed = 0;
|
((string_type *)s)->hdr.grayed = 0;
|
||||||
((string_type *)s)->tag = string_tag;
|
((string_type *)s)->tag = string_tag;
|
||||||
((string_type *)s)->len = len;
|
((string_type *)s)->len = len;
|
||||||
|
((string_type *)s)->num_cp = num_cp;
|
||||||
((string_type *)s)->str = alloca(sizeof(char) * (len + 1));
|
((string_type *)s)->str = alloca(sizeof(char) * (len + 1));
|
||||||
}
|
}
|
||||||
memset(((string_type *)s)->str, c, len);
|
memset(((string_type *)s)->str, c, len);
|
||||||
|
|
Loading…
Add table
Reference in a new issue