mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Issue #81 - Fixes for bytevector-copy
This commit is contained in:
parent
8f602e55c3
commit
741fcc6a0a
2 changed files with 22 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
Bug Fixes
|
||||
|
||||
- Fixed `utf8->string`, `string->utf8`, `list->vector`, and `list->string` to use the heap to allocate objects that exceed the maximum size for objects on the stack.
|
||||
- Fixed `utf8->string`, `string->utf8`, `bytevector-copy`, `list->vector`, and `list->string` to use the heap to allocate objects that exceed the maximum size for objects on the stack.
|
||||
|
||||
## 0.7.1 - December 21, 2017
|
||||
|
||||
|
|
26
runtime.c
26
runtime.c
|
@ -2610,7 +2610,6 @@ object Cyc_bytevector_copy(void *data, object cont, object bv, object start,
|
|||
{
|
||||
int s, e;
|
||||
int len;
|
||||
make_empty_bytevector(result);
|
||||
|
||||
Cyc_check_bvec(data, bv);
|
||||
Cyc_check_num(data, start);
|
||||
|
@ -2628,10 +2627,27 @@ object Cyc_bytevector_copy(void *data, object cont, object bv, object start,
|
|||
Cyc_rt_raise2(data, "bytevector-copy - invalid end", end);
|
||||
}
|
||||
|
||||
result.len = len;
|
||||
result.data = alloca(sizeof(char) * len);
|
||||
memcpy(&result.data[0], &(((bytevector) bv)->data)[s], len);
|
||||
_return_closcall1(data, cont, &result);
|
||||
if (len >= MAX_STACK_OBJ) {
|
||||
int heap_grown;
|
||||
object result = gc_alloc(((gc_thread_data *)data)->heap,
|
||||
sizeof(bytevector_type) + len,
|
||||
boolean_f, // OK to populate manually over here
|
||||
(gc_thread_data *)data,
|
||||
&heap_grown);
|
||||
((bytevector) result)->hdr.mark = ((gc_thread_data *)data)->gc_alloc_color;
|
||||
((bytevector) result)->hdr.grayed = 0;
|
||||
((bytevector) result)->tag = bytevector_tag;
|
||||
((bytevector) result)->len = len;
|
||||
((bytevector) result)->data = (char *)(((char *)result) + sizeof(bytevector_type));
|
||||
memcpy(&(((bytevector) result)->data[0]), &(((bytevector) bv)->data)[s], len);
|
||||
_return_closcall1(data, cont, result);
|
||||
} else {
|
||||
make_empty_bytevector(result);
|
||||
result.len = len;
|
||||
result.data = alloca(sizeof(char) * len);
|
||||
memcpy(&result.data[0], &(((bytevector) bv)->data)[s], len);
|
||||
_return_closcall1(data, cont, &result);
|
||||
}
|
||||
}
|
||||
|
||||
object Cyc_utf82string(void *data, object cont, object bv, object start,
|
||||
|
|
Loading…
Add table
Reference in a new issue