mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-04 00:30:30 +02:00
Pin bytevector parents
* libguile/bytevectors.c (make_bytevector_from_buffer): If there is a parent GC-managed object for the buffer, pin that object so that the buffer remains valid.
This commit is contained in:
parent
c79d5bd0f7
commit
fecd6c00e4
1 changed files with 5 additions and 2 deletions
|
@ -258,9 +258,9 @@ make_bytevector_from_buffer (size_t len, void *contents,
|
||||||
|
|
||||||
size_t bytes_per_elt = scm_i_array_element_type_sizes[element_type]/8;
|
size_t bytes_per_elt = scm_i_array_element_type_sizes[element_type]/8;
|
||||||
size_t c_len = len * bytes_per_elt;
|
size_t c_len = len * bytes_per_elt;
|
||||||
|
scm_thread *thr = SCM_I_CURRENT_THREAD;
|
||||||
struct scm_bytevector *bv =
|
struct scm_bytevector *bv =
|
||||||
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
scm_allocate_tagged (thr, sizeof (struct scm_bytevector));
|
||||||
sizeof (struct scm_bytevector));
|
|
||||||
|
|
||||||
scm_t_bits flags = is_immutable ? SCM_F_BYTEVECTOR_IMMUTABLE : 0;
|
scm_t_bits flags = is_immutable ? SCM_F_BYTEVECTOR_IMMUTABLE : 0;
|
||||||
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
||||||
|
@ -268,6 +268,9 @@ make_bytevector_from_buffer (size_t len, void *contents,
|
||||||
bv->contents = contents;
|
bv->contents = contents;
|
||||||
bv->parent = parent;
|
bv->parent = parent;
|
||||||
|
|
||||||
|
if (scm_is_true (parent))
|
||||||
|
scm_gc_pin_object (thr, parent);
|
||||||
|
|
||||||
return bv;
|
return bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue