[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb643
From: |
Ludovic Courtès |
Subject: |
Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509 |
Date: |
Sat, 06 Jun 2009 16:31:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux) |
Hello,
"Andy Wingo" <address@hidden> writes:
> +SCM_DEFINE (scm_uniform_array_to_bytevector, "uniform-array->bytevector",
> + 1, 0, 0, (SCM array),
> + "Return a newly allocated bytevector whose contents\n"
> + "will be copied from the uniform array @var{array}.")
> +#define FUNC_NAME s_scm_uniform_array_to_bytevector
> +{
> + SCM contents, ret;
> + size_t len;
> + scm_t_array_handle h;
> + const void *base;
> + size_t sz;
> +
> + contents = scm_array_contents (array, SCM_BOOL_T);
> + if (scm_is_false (contents))
> + scm_wrong_type_arg_msg (FUNC_NAME, 0, array, "uniform contiguous array");
> +
> + scm_array_get_handle (contents, &h);
> +
> + base = scm_array_handle_uniform_elements (&h);
> + len = h.dims->inc * (h.dims->ubnd - h.dims->lbnd + 1);
> + sz = scm_array_handle_uniform_element_size (&h);
> +
> + ret = make_bytevector (len * sz);
> + memcpy (SCM_BYTEVECTOR_CONTENTS (ret), base, len * sz);
Is this memcpy valid in the case of shared arrays? Looks like we end up
copying more elements than needed, but maybe it's better this way.
> + uniform-array->bytevector
I would not export it from `(rnrs bytevector)' given that it has nothing
to do with RnRS.
Also, I would make the new C functions private, given that they are not
intended for general use AIUI.
What d'ya think?
Thanks,
Ludo'.
- Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509,
Ludovic Courtès <=