diff options
Diffstat (limited to 'src/struct.c')
-rw-r--r-- | src/struct.c | 24 |
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; +} |