1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Allow scm_XXX_writable_elements on empty vectors, even if immutable

* libguile/array-handle.c (initialize_vector_handle): Set both element
  pointers to NULL if the vector is empty.
* libguile/array-map.c (racp): Ignore immutability if destination is
  empty.
* test-suite/tests/sort.test: Check empty/mutable/immutable vectors with
  sort!.
* test-suite/tests/array-map.test: Check array-copy! with
  empty/immutable destination.
This commit is contained in:
Daniel Llorens 2017-09-15 12:36:57 +02:00
parent 1008ea3154
commit 4212f29655
4 changed files with 30 additions and 12 deletions

View file

@ -263,7 +263,7 @@ racp (SCM src, SCM dst)
{
SCM const * el_s = h_s.elements;
SCM * el_d = h_d.writable_elements;
if (!el_d)
if (!el_d && n>0)
scm_wrong_type_arg_msg ("array-copy!", SCM_ARG2, dst, "mutable array");
for (; n-- > 0; i_s += inc_s, i_d += inc_d)
el_d[i_d] = el_s[i_s];