1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Fix array-index-map refactor

* libguile/ramap.c (array_index_map_1): Fix to use array handle
  properly.
This commit is contained in:
Andy Wingo 2014-02-06 21:34:14 +01:00
parent f0521cdabc
commit 828ada1326

View file

@ -778,24 +778,29 @@ SCM_DEFINE (scm_array_for_each, "array-for-each", 2, 0, 1,
}
#undef FUNC_NAME
static SCM
static void
array_index_map_1 (SCM ra, SCM proc)
{
unsigned long i;
size_t length = scm_c_array_length (ra);
for (i = 0; i < length; ++i)
ASET (ra, i, scm_call_1 (proc, scm_from_ulong (i)));
return SCM_UNSPECIFIED;
scm_t_array_handle h;
ssize_t i, inc;
size_t p;
SCM v;
scm_array_get_handle (ra, &h);
v = h.array;
inc = h.dims[0].inc;
for (i = h.dims[0].lbnd, p = h.base; i <= h.dims[0].ubnd; ++i, p += inc)
h.impl->vset (&h, p, scm_call_1 (proc, scm_from_ulong (i)));
scm_array_handle_release (&h);
}
/* Here we assume that the array is a scm_tc7_array, as that is the only
kind of array in Guile that supports rank > 1. */
static SCM
static void
array_index_map_n (SCM ra, SCM proc)
{
size_t i;
SCM args = SCM_EOL;
int j, k, kmax = SCM_I_ARRAY_NDIM (ra) - 1;
unsigned long i;
long *vinds;
vinds = scm_gc_malloc_pointerless (sizeof(long) * SCM_I_ARRAY_NDIM (ra),
@ -830,8 +835,6 @@ array_index_map_n (SCM ra, SCM proc)
k--;
}
while (k >= 0);
return SCM_UNSPECIFIED;
}
SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0,