summaryrefslogtreecommitdiff
path: root/libguile/vectors.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/vectors.c')
-rw-r--r--libguile/vectors.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 3848a8bbb..292252ebd 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -184,7 +184,7 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
register SCM *data;
int i;
SCM_VALIDATE_LIST_COPYLEN (1,l,i);
- res = scm_make_vector (SCM_MAKINUM (i), SCM_UNSPECIFIED);
+ res = scm_c_make_vector (i, SCM_UNSPECIFIED);
data = SCM_VELTS (res);
for(; i && SCM_NIMP(l); --i, l = SCM_CDR (l))
*data++ = SCM_CAR (l);
@@ -270,30 +270,35 @@ SCM_DEFINE (scm_make_vector, "make-vector", 1, 1, 0,
"Otherwise the initial contents of each element is unspecified. (r5rs)")
#define FUNC_NAME s_scm_make_vector
{
- SCM v;
- unsigned long int i;
- scm_bits_t *velts;
-
SCM_VALIDATE_INUM_MIN (1, k, 0);
if (SCM_UNBNDP (fill))
fill = SCM_UNSPECIFIED;
+ return scm_c_make_vector (SCM_INUM (k), fill);
+}
+#undef FUNC_NAME
+
+SCM
+scm_c_make_vector (unsigned long int k, SCM fill)
+#define FUNC_NAME s_scm_make_vector
+{
+ SCM v;
+ scm_bits_t *velts;
- i = SCM_INUM (k);
SCM_NEWCELL (v);
- velts = (i != 0)
- ? scm_must_malloc (i * sizeof (scm_bits_t), FUNC_NAME)
+ velts = (k != 0)
+ ? scm_must_malloc (k * sizeof (scm_bits_t), FUNC_NAME)
: NULL;
SCM_DEFER_INTS;
{
unsigned long int j;
- for (j = 0; j != i; ++j)
+ for (j = 0; j != k; ++j)
velts[j] = SCM_UNPACK (fill);
SCM_SET_VECTOR_BASE (v, velts);
- SCM_SET_VECTOR_LENGTH (v, i, scm_tc7_vector);
+ SCM_SET_VECTOR_LENGTH (v, k, scm_tc7_vector);
}
SCM_ALLOW_INTS;
@@ -301,7 +306,6 @@ SCM_DEFINE (scm_make_vector, "make-vector", 1, 1, 0,
}
#undef FUNC_NAME
-
SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
(SCM v),
"@samp{Vector->list} returns a newly allocated list of the objects contained\n"