newJoyList

This commit is contained in:
Simon Forman 2023-02-03 09:18:32 -08:00
parent fb40b11fb0
commit 8647f40895
2 changed files with 6 additions and 9 deletions

View File

@ -64,8 +64,7 @@ my_callback(GC_PTR void_obj, __attribute__((unused)) GC_PTR void_environment) {
JoyList JoyList
push_integer_from_str(char *str, JoyList tail) push_integer_from_str(char *str, JoyList tail)
{ {
JoyList el; JoyList el = newJoyList;
el = GC_malloc(sizeof(struct list_node));
el->head.kind = joyInt; el->head.kind = joyInt;
mpz_init_set_str(el->head.value.i, str, 10); mpz_init_set_str(el->head.value.i, str, 10);
GC_register_finalizer(el->head.value.i, my_callback, NULL, NULL, NULL); GC_register_finalizer(el->head.value.i, my_callback, NULL, NULL, NULL);
@ -130,11 +129,9 @@ trim_leading_blanks(char *str)
JoyList JoyList
make_non_list_node(char *text, size_t size) make_non_list_node(char *text, size_t size)
{ {
struct list_node *node;
char *sym; char *sym;
const struct dict_entry *interned; const struct dict_entry *interned;
JoyList node = newJoyList;
node = GC_malloc(sizeof(struct list_node));
interned = in_word_set(text, size); interned = in_word_set(text, size);
if (interned) { if (interned) {
@ -169,13 +166,11 @@ make_non_list_node(char *text, size_t size)
return node; return node;
} }
/* Create a new list_node with a joyList head. */ /* Create a new list_node with a joyList head. */
JoyList JoyList
make_list_node(struct list_node *el) make_list_node(JoyList el)
{ {
struct list_node *node; JoyList node = newJoyList;
node = GC_malloc(sizeof(struct list_node));
node->head.kind = joyList; node->head.kind = joyList;
node->head.value.el = el; node->head.value.el = el;
return node; return node;

View File

@ -49,6 +49,8 @@ struct list_node {
#define EMPTY_LIST (JoyList)NULL #define EMPTY_LIST (JoyList)NULL
#define newJoyList GC_malloc(sizeof(struct list_node))
typedef void (*JoyFunc)(struct list_node**, struct list_node**); typedef void (*JoyFunc)(struct list_node**, struct list_node**);