summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/array-handle.c4
-rw-r--r--libguile/generalized-vectors.c5
-rw-r--r--libguile/vectors.c19
3 files changed, 5 insertions, 23 deletions
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 3595266ff..89277d9d6 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -320,9 +320,7 @@ scm_array_handle_release (scm_t_array_handle *h)
const SCM *
scm_array_handle_elements (scm_t_array_handle *h)
{
- if (h->element_type != SCM_ARRAY_ELEMENT_TYPE_SCM)
- scm_wrong_type_arg_msg (NULL, 0, h->array, "non-uniform array");
- return ((const SCM*)h->elements) + h->base;
+ return scm_array_handle_writable_elements (h);
}
SCM *
diff --git a/libguile/generalized-vectors.c b/libguile/generalized-vectors.c
index 0fe8b897c..276b9d865 100644
--- a/libguile/generalized-vectors.c
+++ b/libguile/generalized-vectors.c
@@ -69,11 +69,6 @@ SCM_DEFINE (scm_make_generalized_vector, "make-generalized-vector", 2, 1, 0,
}
#undef FUNC_NAME
-
-#define SCM_VALIDATE_VECTOR_WITH_HANDLE(pos, val, handle) \
- scm_generalized_vector_get_handle (val, handle)
-
-
void
scm_generalized_vector_get_handle (SCM vec, scm_t_array_handle *h)
{
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 7ee7898c5..b9613c50f 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -58,23 +58,15 @@ const SCM *
scm_vector_elements (SCM vec, scm_t_array_handle *h,
size_t *lenp, ssize_t *incp)
{
- if (SCM_I_WVECTP (vec))
- scm_wrong_type_arg_msg (NULL, 0, vec, "non-weak vector");
-
- scm_generalized_vector_get_handle (vec, h);
- if (lenp)
- {
- scm_t_array_dim *dim = scm_array_handle_dims (h);
- *lenp = dim->ubnd - dim->lbnd + 1;
- *incp = dim->inc;
- }
- return scm_array_handle_elements (h);
+ /* guard against weak vectors in the next call */
+ return scm_vector_writable_elements (vec, h, lenp, incp);
}
SCM *
scm_vector_writable_elements (SCM vec, scm_t_array_handle *h,
size_t *lenp, ssize_t *incp)
{
+ /* it's unsafe to access the memory of a weak vector */
if (SCM_I_WVECTP (vec))
scm_wrong_type_arg_msg (NULL, 0, vec, "non-weak vector");
@@ -140,12 +132,11 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
SCM res;
SCM *data;
long i, len;
- scm_t_array_handle handle;
SCM_VALIDATE_LIST_COPYLEN (1, l, len);
res = scm_c_make_vector (len, SCM_UNSPECIFIED);
- data = scm_vector_writable_elements (res, &handle, NULL, NULL);
+ data = SCM_I_VECTOR_WELTS (res);
i = 0;
while (scm_is_pair (l) && i < len)
{
@@ -154,8 +145,6 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
i += 1;
}
- scm_array_handle_release (&handle);
-
return res;
}
#undef FUNC_NAME