Compute number of code points and byte len

This commit is contained in:
Justin Ethier 2017-10-24 17:53:09 -04:00
parent 13254d06f0
commit 6c4dd4b740

View file

@ -952,7 +952,8 @@
" object s = NULL;
Cyc_check_int(data, count);
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) {
int heap_grown;
s = gc_alloc(((gc_thread_data *)data)->heap,
@ -964,6 +965,7 @@
((string_type *) s)->hdr.grayed = 0;
((string_type *) s)->tag = string_tag;
((string_type *) s)->len = len;
((string_type *) s)->num_cp = num_cp;
((string_type *) s)->str = (((char *)s) + sizeof(string_type));
} else {
s = alloca(sizeof(string_type));
@ -971,6 +973,7 @@
((string_type *)s)->hdr.grayed = 0;
((string_type *)s)->tag = string_tag;
((string_type *)s)->len = len;
((string_type *)s)->num_cp = num_cp;
((string_type *)s)->str = alloca(sizeof(char) * (len + 1));
}
memset(((string_type *)s)->str, c, len);