7 struct familia_family * familia_family_new()
9 struct familia_family * family = NULL;
10 family = malloc(sizeof(struct familia_family));
13 debug("["__FILE__ "] There was a problem with allocating memory for family.\n");
18 family->individual1 = NULL;
19 family->individual2 = NULL;
21 family->children = NULL;
22 family->children_no = 0;
27 void familia_family_free(struct familia_family * family)
29 family->individual1 = NULL;
30 family->individual2 = NULL;
32 if (family->children) {
34 /* Remove all children links. */
35 for (; i < family->children_no; i++) {
36 family->children[i] = NULL;
38 free(family->children);
39 family->children = NULL;
40 family->children_no = 0;
46 void familia_family_set_individual(struct familia_family * family, struct familia_individual * individual, enum FFamilyIndividualIndex index)
50 family->individual1 = individual;
53 family->individual2 = individual;
58 struct familia_individual * familia_family_get_individual(struct familia_family * family, enum FFamilyIndividualIndex index)
60 struct familia_individual * individual = NULL;
64 individual = family->individual1;
66 individual = family->individual2;
72 struct familia_individual * familia_family_remove_individual(struct familia_family * family, enum FFamilyIndividualIndex index)
74 struct familia_individual * individual = NULL;
78 individual = family->individual1;
79 family->individual1 = NULL;
81 individual = family->individual2;
82 family->individual2 = NULL;
88 void familia_family_add_child(struct familia_family * family, struct familia_individual * individual)
90 struct familia_individual ** tmp = NULL;
91 int size = (family->children_no + 1);
93 tmp = realloc(family->children, size * sizeof(struct familia_individual *));
96 family->children = tmp;
97 family->children[family->children_no] = individual;
98 family->children_no++;
101 debug("There were problems with allocating memory for family children.\n");
105 struct familia_individual * familia_family_get_child_by_id(struct familia_family * family, unsigned short index)
107 struct familia_individual * child = NULL;
109 if (index < family->children_no) {
110 child = family->children[index];
116 struct familia_individual * familia_family_remove_child_by_id(struct familia_family * family, unsigned short index)
118 struct familia_individual * child = NULL;
120 child = familia_family_get_child_by_id(family, index);
124 family->children[index] = NULL;
126 for (; i < family->children_no - 1; i++) {
127 family->children[i] = family->children[i + 1];
130 family->children[--(family->children_no)] = NULL;