summaryrefslogtreecommitdiff
path: root/libguile/srfi-4.i.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-09-02 00:07:27 +0200
committerLudovic Courtès <ludo@gnu.org>2009-09-02 01:37:37 +0200
commit5f236208d0d864546e59afa0f5a11c9b3ba14b10 (patch)
treeeed5d9203a2633c8efb85c1b36425eab87574299 /libguile/srfi-4.i.c
parentf0eb5ae6c173aed35965b0561897fda1d8ff0db1 (diff)
parentd7e7a02a6251c8ed4f76933d9d30baeee3f599c0 (diff)
downloadguile-5f236208d0d864546e59afa0f5a11c9b3ba14b10.tar.gz
Merge branch 'boehm-demers-weiser-gc' into bdw-gc-static-alloc
Conflicts: acinclude.m4 libguile/strings.c
Diffstat (limited to 'libguile/srfi-4.i.c')
-rw-r--r--libguile/srfi-4.i.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/libguile/srfi-4.i.c b/libguile/srfi-4.i.c
index 58a52c1d8..098752ef2 100644
--- a/libguile/srfi-4.i.c
+++ b/libguile/srfi-4.i.c
@@ -121,24 +121,21 @@ SCM_DEFINE (F(scm_list_to_,TAG,vector), "list->"S(TAG)"vector", 1, 0, 0,
}
#undef FUNC_NAME
-SCM_DEFINE (F(scm_any_to_,TAG,vector), "any->"S(TAG)"vector", 1, 0, 0,
- (SCM obj),
- "Convert @var{obj}, which can be a list, vector, or\n"
- "uniform vector, to a numeric uniform vector of\n"
- "type " S(TAG)".")
-#define FUNC_NAME s_F(scm_any_to_,TAG,vector)
-{
- return coerce_to_uvec (TYPE, obj);
-}
-#undef FUNC_NAME
-
#ifdef CTYPE
SCM
F(scm_take_,TAG,vector) (CTYPE *data, size_t n)
{
- scm_gc_register_collectable_memory ((void *)data, n*uvec_sizes[TYPE],
- uvec_names[TYPE]);
+ /* The manual says "Return a new uniform numeric vector [...] that uses the
+ memory pointed to by DATA". We *have* to use DATA as the underlying
+ storage; thus we must register a finalizer to eventually free(3) it. */
+ GC_finalization_proc prev_finalizer;
+ GC_PTR prev_finalization_data;
+
+ GC_REGISTER_FINALIZER_NO_ORDER (data, free_user_data, 0,
+ &prev_finalizer,
+ &prev_finalization_data);
+
return take_uvec (TYPE, data, n);
}
@@ -187,13 +184,13 @@ F(scm_,TAG,vector_writable_elements) (SCM uvec,
#endif
static SCM
-F(,TAG,ref) (scm_t_array_handle *handle, ssize_t pos)
+F(,TAG,ref) (scm_t_array_handle *handle, size_t pos)
{
return uvec_fast_ref (TYPE, handle->elements, pos);
}
static void
-F(,TAG,set) (scm_t_array_handle *handle, ssize_t pos, SCM val)
+F(,TAG,set) (scm_t_array_handle *handle, size_t pos, SCM val)
{
uvec_fast_set_x (TYPE, handle->writable_elements, pos, val);
}