summaryrefslogtreecommitdiff
path: root/src/struct.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-12-25 11:46:23 -0500
committerAdrian Thurston <thurston@complang.org>2014-12-25 11:46:23 -0500
commit4bd915e48b6b6278ed8c4b7be95781535f2ce10a (patch)
treec87f8057ba33a56490dcce1f332129acdfd66202 /src/struct.c
parent353ddb63f7268d2cc96df328c8562b4f3050d1d6 (diff)
downloadcolm-4bd915e48b6b6278ed8c4b7be95781535f2ce10a.tar.gz
some renaming and cleanup
Diffstat (limited to 'src/struct.c')
-rw-r--r--src/struct.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/struct.c b/src/struct.c
new file mode 100644
index 00000000..8a13e9b5
--- /dev/null
+++ b/src/struct.c
@@ -0,0 +1,24 @@
+#include <colm/program.h>
+#include <colm/struct.h>
+
+struct colm_struct *colm_new_struct( Program *prg, int id )
+{
+ int structSize = prg->rtd->selInfo[id].size;
+ size_t memsize = sizeof(struct colm_struct) + ( sizeof(Tree*) * structSize );
+ struct colm_struct *item = (struct colm_struct*) malloc( memsize );
+ memset( item, 0, memsize );
+ item->id = id;
+
+ if ( prg->heap.head == 0 ) {
+ prg->heap.head = prg->heap.tail = item;
+ item->prev = item->next = 0;
+ }
+ else {
+ item->prev = prg->heap.tail;
+ item->next = 0;
+ prg->heap.tail->next = item;
+ prg->heap.tail = item;
+ }
+
+ return item;
+}