summaryrefslogtreecommitdiff
path: root/src/struct.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-01-04 15:17:41 -0500
committerAdrian Thurston <thurston@complang.org>2015-01-04 15:17:41 -0500
commit07547abf01f117076f36587f462a68dae0959b11 (patch)
tree33fa9bd30c363375f039112893151c4d0904b786 /src/struct.c
parent26ae0bcd0891fc2ace430c6258dadd17607595de (diff)
downloadcolm-07547abf01f117076f36587f462a68dae0959b11.tar.gz
turning list elements into allocated objects
Diffstat (limited to 'src/struct.c')
-rw-r--r--src/struct.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/struct.c b/src/struct.c
index 1667b864..8d03583f 100644
--- a/src/struct.c
+++ b/src/struct.c
@@ -110,7 +110,7 @@ void colm_list_destroy( Program *prg, Tree **sp, struct colm_struct *s )
ListEl *el = list->head;
while ( el != 0 ) {
- ListEl *next = el->next;
+ ListEl *next = el->list_next;
treeDownref( prg, sp, el->value );
//listElFree( prg, el );
el = next;
@@ -157,10 +157,10 @@ Tree *colm_list_get( List *list, Word field )
Tree *result = 0;
switch ( field ) {
case 0:
- result = list->head;
+ result = (Tree*)list->head;
break;
case 1:
- result = list->tail;
+ result = (Tree*)list->tail;
break;
default:
assert( 0 );
@@ -174,10 +174,10 @@ Tree *colm_list_el_get( ListEl *listEl, Word field )
Tree *result = 0;
switch ( field ) {
case 0:
- result = listEl->prev;
+ result = listEl->list_prev;
break;
case 1:
- result = listEl->next;
+ result = listEl->list_next;
break;
case 2:
result = listEl->value;
@@ -190,3 +190,13 @@ Tree *colm_list_el_get( ListEl *listEl, Word field )
return result;
}
+struct colm_list_el *colm_list_el_new( struct colm_program *prg )
+{
+ size_t memsize = sizeof(struct colm_list_el);
+ struct colm_list_el *el = (struct colm_list_el*) malloc( memsize );
+ memset( el, 0, memsize );
+ colm_struct_add( prg, (struct colm_struct *)el );
+ el->id = STRUCT_INBUILT_ID;
+ return el;
+}
+