-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentries.c
78 lines (54 loc) · 1.26 KB
/
entries.c
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
77
#include "entries.h"
#include <stdio.h>
#include <stdlib.h>
struct entry
{
int id;
void* properties;
void* friends; //deiktis se lista filon
};
struct edge
{
int id; //id filou
void* lista_idiotiton; //knows,respect,etc
};
ptr_entry create_entry(int id,void* properties,int (*match)( const void *a, const void *b)) //create node
{
ptr_entry node;
node = malloc(sizeof(struct entry));
node->id = id;
node->properties = properties;
//node->friends = NULL;
node->friends = (void*) LL_create(match);
return node;
}
void destroy_entry(void* entry)
{
ptr_entry this = (ptr_entry) entry;
if(this->properties != NULL)
{
LL_destroy((list_ptr)this->properties,NULL); //sto null xreiazete mia destroy gia tin lista idiotiton
}
if(this->properties != NULL)
{
LL_destroy( (list_ptr)this->friends,destroy_edge);
}
free(this);
}
ptr_edge create_edge(int id, void* lista_idiotiton)
{
ptr_edge akmh;
akmh = malloc(sizeof(struct edge));
akmh->id = id;
akmh->lista_idiotiton = lista_idiotiton;
return akmh;
}
void destroy_edge(void* edge)
{
ptr_edge this = (ptr_edge) edge;
if(this->lista_idiotiton != NULL)
{
LL_destroy((list_ptr)this->lista_idiotiton,NULL); //sto null xreiazete mia destroy gia tin lista idiotiton
}
free(this);
}