File: generic.c

package info (click to toggle)
treetool 2.0.2a-4
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 1,172 kB
  • ctags: 2,694
  • sloc: ansic: 26,504; makefile: 215
file content (76 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (5)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>

#ifdef MEMDBG
#include "memdbg.h"
#endif

#include "treestruct.h"

treegen newspace(t)
/* allocates space for a new data item */
data_type t;
{
	treegen tmp;

	switch(t)
	{
		case tr_tree:
			tmp=(treegen)malloc(sizeof(treed));
			break;
		case tr_node:
			tmp=(treegen)malloc(sizeof(treenoded));
			break;
		case tr_branch:
			tmp=(treegen)malloc(sizeof(treebranchd));
			break;
		default:
			tmp=NULL;
			break;
	}
	if(tmp==NULL)
		return(NULL);
	tmp->type=t;
	tmp->t=NULL;
	tmp->intdata=NULL;
	tmp->data=NULL;
	return(tmp);
}

tree tree_get_tree(i)
treegen i;
{
	if(i==NULL)
		return(0);
	return(i->t);
}

void *tree_get_tree_data(i)
treegen i;
{
	if(i==NULL)
		return(NULL);
	return(((treegen)i->t)->data);
}

int tree_set_tree(i, d)
treegen i;
void *d;
{
	if(i==NULL)
		return(0);
	i->t=d;
	return(1);
}

char *tree_get_name(i)
treegen i;
{
	if(i==NULL)
		return(NULL);
	if(i->type==tr_tree)
		return(((tree)i)->name);
	else if(i->type==tr_node)
		return(((treenode)i)->name);
	else
		return(NULL);
}