1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2001-2008, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <common/ac/assert.h>
21
22 #include <common/trace.h>
23 #include <libaegis/change/branch.h>
24
25
26 void
change_branch_change_add(change::pointer cp,long change_number,int is_a_branch)27 change_branch_change_add(change::pointer cp, long change_number,
28 int is_a_branch)
29 {
30 cstate_ty *cstate_data;
31 meta_type *type_p;
32 long *addr;
33 cstate_branch_change_list_ty *lp;
34 size_t j;
35
36 //
37 // add it to the change list
38 //
39 trace(("change_branch_change_add(cp = %p, change_number = %ld)\n{\n",
40 cp, change_number));
41 cstate_data = cp->cstate_get();
42 assert(cstate_data->branch);
43 if (!cstate_data->branch->change)
44 {
45 cstate_data->branch->change =
46 (cstate_branch_change_list_ty *)
47 cstate_branch_change_list_type.alloc();
48 }
49 lp = cstate_data->branch->change;
50
51 //
52 // make sure we don't have it already
53 //
54 for (j = 0; j < lp->length; ++j)
55 if (change_number == lp->list[j])
56 break;
57
58 //
59 // append it to the list
60 //
61 if (j >= lp->length)
62 {
63 addr =
64 (long int *)
65 cstate_branch_change_list_type.list_parse
66 (
67 cstate_data->branch->change,
68 &type_p
69 );
70 assert(type_p == &integer_type);
71 *addr = change_number;
72 }
73
74 if (is_a_branch)
75 {
76 cstate_branch_sub_branch_list_ty *lp2;
77
78 //
79 // add it to the change list
80 //
81 if (!cstate_data->branch->sub_branch)
82 {
83 cstate_data->branch->sub_branch =
84 (cstate_branch_sub_branch_list_ty *)
85 cstate_branch_sub_branch_list_type.alloc();
86 }
87 lp2 = cstate_data->branch->sub_branch;
88
89 //
90 // make sure we don't have it already
91 //
92 for (j = 0; j < lp2->length; ++j)
93 if (change_number == lp2->list[j])
94 break;
95
96 //
97 // append it to the list
98 //
99 if (j >= lp2->length)
100 {
101 addr =
102 (long int *)
103 cstate_branch_change_list_type.list_parse
104 (
105 cstate_data->branch->sub_branch,
106 &type_p
107 );
108 assert(type_p == &integer_type);
109 *addr = change_number;
110 }
111 }
112 trace(("}\n"));
113 }
114
115
116 // vim: set ts=8 sw=4 et :
117