blob: 5b37cb27f3023c6ec5c1191a43c4f3111276ee00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <colm/program.h>
#include <colm/struct.h>
#include <stdlib.h>
#include <string.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;
}
void colm_delete_struct( Program *prg, Tree **sp, struct colm_struct *el )
{
short *t = prg->rtd->selInfo[el->id].trees;
int i, len = prg->rtd->selInfo[el->id].treesLen;
for ( i = 0; i < len; i++ )
treeDownref( prg, sp, ((Tree**)(el+1))[t[i]] );
free( el );
}
|