From b655859822b77df8722e7ae6d7bc21df26d5a894 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Mon, 14 Oct 2019 00:43:00 +0300 Subject: [PATCH] Add more C-side accum helpers --- c/scheme.h | 2 ++ c/util.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/c/scheme.h b/c/scheme.h index 672e646..6448165 100644 --- a/c/scheme.h +++ b/c/scheme.h @@ -1053,9 +1053,11 @@ struct accum { .list = FL_NIL, .tail = FL_NIL \ } +void accum_init(struct accum *accum); void accum_elt(struct accum *accum, value_t elt); void accum_pair(struct accum *accum, value_t a, value_t d); void accum_name_value(struct accum *accum, const char *name, value_t value); +void accum_name_value1(struct accum *accum, const char *name, value_t value); struct sv_accum { char **vec; diff --git a/c/util.c b/c/util.c index da1af25..c1690af 100644 --- a/c/util.c +++ b/c/util.c @@ -21,6 +21,8 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size) // +void accum_init(struct accum *accum) { accum->list = accum->tail = FL_NIL; } + void accum_elt(struct accum *accum, value_t elt) { value_t newtail; @@ -41,7 +43,12 @@ void accum_pair(struct accum *accum, value_t a, value_t d) void accum_name_value(struct accum *accum, const char *name, value_t value) { - accum_pair(accum, string_from_cstr(name), value); + accum_pair(accum, symbol(name), value); +} + +void accum_name_value1(struct accum *accum, const char *name, value_t value) +{ + accum_pair(accum, symbol(name), fl_cons(value, FL_NIL)); } //