From 4212f29655db2e9ddca19ebd590bca5521c1b97b Mon Sep 17 00:00:00 2001 From: Daniel Llorens Date: Fri, 15 Sep 2017 12:36:57 +0200 Subject: 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. --- libguile/array-map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libguile/array-map.c') diff --git a/libguile/array-map.c b/libguile/array-map.c index 79383969d..651a1bfb9 100644 --- a/libguile/array-map.c +++ b/libguile/array-map.c @@ -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]; -- cgit v1.2.3