summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2013-04-17 17:29:36 +0200
committerAndy Wingo <wingo@pobox.com>2014-01-27 21:45:18 +0100
commit3e226ece5fc6f87cac2d02948177cafe61977bc4 (patch)
treeec4709e44b9387a52c236189095ba8bea67a7bc7
parent95cd688421175870b22f71409fb4ef24124d68d0 (diff)
downloadguile-3e226ece5fc6f87cac2d02948177cafe61977bc4.tar.gz
Avoid using array_handle fields in impl->vref/vset
* libguile/bytevectors.c: (bv_handle_set_x, bv_handle_ref): get length and element type fields from the bytevector, not from the handle. * libguile/vectors.c: (vector_handle_set, vector_handle_ref): get length from the vector, not from the handle.
-rw-r--r--libguile/bytevectors.c4
-rw-r--r--libguile/vectors.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index 70663880b..f197be342 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -2154,7 +2154,7 @@ bv_handle_ref (scm_t_array_handle *h, size_t index)
SCM byte_index;
scm_t_bytevector_ref_fn ref_fn;
- ref_fn = bytevector_ref_fns[h->element_type];
+ ref_fn = bytevector_ref_fns[SCM_BYTEVECTOR_ELEMENT_TYPE (h->array)];
byte_index =
scm_from_size_t (index * SCM_BYTEVECTOR_TYPE_SIZE (h->array));
return ref_fn (h->array, byte_index);
@@ -2217,7 +2217,7 @@ bv_handle_set_x (scm_t_array_handle *h, size_t index, SCM val)
SCM byte_index;
scm_t_bytevector_set_fn set_fn;
- set_fn = bytevector_set_fns[h->element_type];
+ set_fn = bytevector_set_fns[SCM_BYTEVECTOR_ELEMENT_TYPE (h->array)];
byte_index =
scm_from_size_t (index * SCM_BYTEVECTOR_TYPE_SIZE (h->array));
set_fn (h->array, byte_index, val);
diff --git a/libguile/vectors.c b/libguile/vectors.c
index ae7c3e9c4..74d8a7ccb 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -436,17 +436,17 @@ SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0,
static SCM
vector_handle_ref (scm_t_array_handle *h, size_t idx)
{
- if (idx > h->dim0.ubnd)
+ if (idx >= SCM_I_VECTOR_LENGTH (h->array))
scm_out_of_range ("vector-handle-ref", scm_from_size_t (idx));
- return ((SCM*)h->elements)[idx];
+ return SCM_I_VECTOR_WELTS(h->array)[idx];
}
static void
vector_handle_set (scm_t_array_handle *h, size_t idx, SCM val)
{
- if (idx > h->dim0.ubnd)
+ if (idx >= SCM_I_VECTOR_LENGTH (h->array))
scm_out_of_range ("vector-handle-set!", scm_from_size_t (idx));
- ((SCM*)h->writable_elements)[idx] = val;
+ SCM_I_VECTOR_WELTS(h->array)[idx] = val;
}
static void