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:
parent
1008ea3154
commit
4212f29655
4 changed files with 30 additions and 12 deletions
|
@ -149,8 +149,10 @@ initialize_vector_handle (scm_t_array_handle *h, size_t len,
|
|||
h->dim0.ubnd = (ssize_t) (len - 1U);
|
||||
h->dim0.inc = 1;
|
||||
h->element_type = element_type;
|
||||
h->elements = elements;
|
||||
h->writable_elements = mutable_p ? ((void *) elements) : NULL;
|
||||
/* elements != writable_elements is used to check mutability later on.
|
||||
Ignore it if the array is empty. */
|
||||
h->elements = len==0 ? NULL : elements;
|
||||
h->writable_elements = mutable_p ? ((void *) h->elements) : NULL;
|
||||
h->vector = h->array;
|
||||
h->vref = vref;
|
||||
h->vset = vset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue