Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
f1a7683c
Commit
f1a7683c
authored
7 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
Fixed error with reading/writing wrong bit location in ID exist array.
parent
f0a8048e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Add node to computation graph by ID
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/src/computation_graph/computation_graph.c
+6
-6
6 additions, 6 deletions
quad/src/computation_graph/computation_graph.c
with
6 additions
and
6 deletions
quad/src/computation_graph/computation_graph.c
+
6
−
6
View file @
f1a7683c
...
...
@@ -11,9 +11,9 @@ static double exec_input_vals[GRAPH_MAX_INPUTS];
// Macro functions for setting and clearing single bits in int array
// From http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html
#define setBit(A,k) ( A[(k / sizeof(int))] |= (1 << (k % sizeof(int))) )
#define clearBit(A,k) ( A[(k / sizeof(int))] &= ~(1 << (k % sizeof(int))) )
#define testBit(A,k) ( A[(k / sizeof(int))] & (1 << (k % sizeof(int))) )
#define setBit(A,k) ( A[(k /
(8*
sizeof(int))
)
] |= (1 << (k %
(8*
sizeof(int)))
)
)
#define clearBit(A,k) ( A[(k /
(8*
sizeof(int))
)
] &= ~(1 << (k %
(8*
sizeof(int)))
)
)
#define testBit(A,k) ( A[(k /
(8*
sizeof(int))
)
] & (1 << (k %
(8*
sizeof(int)))
)
)
struct
computation_graph
*
create_graph
()
{
struct
computation_graph
*
the_graph
=
malloc
(
sizeof
(
struct
computation_graph
));
...
...
@@ -120,16 +120,16 @@ int graph_add_node_id(struct computation_graph *graph,
if
(
!
node_arr
)
{
return
-
1
;
}
// Number of integers needed to hold new_size bits
size_t
new_exist_size
=
ceil
((
float
)
new_size
/
(
8
*
sizeof
(
int
)));
// ceil(new_size / (bits per int))
int
*
exist_arr
=
realloc
(
graph
->
node_existence
,
sizeof
(
int
)
*
new_exist_size
);
if
(
!
exist_arr
)
{
return
-
1
;}
// Set the newly allocated memory to 0
size_t
old_exist_size
=
ceil
((
float
)
old_size
/
(
8
*
sizeof
(
int
)));
if
(
old_exist_size
!=
new_exist_size
)
{
int
*
exist_arr
=
realloc
(
graph
->
node_existence
,
sizeof
(
int
)
*
new_exist_size
);
if
(
!
exist_arr
)
{
return
-
1
;}
memset
(
exist_arr
+
old_exist_size
,
0
,
(
new_exist_size
-
old_exist_size
)
*
sizeof
(
int
));
graph
->
node_existence
=
exist_arr
;
}
graph
->
size
=
new_size
;
graph
->
nodes
=
node_arr
;
graph
->
node_existence
=
exist_arr
;
}
struct
graph_node
*
new_node
=
&
graph
->
nodes
[
id
];
new_node
->
name
=
strdup
(
name
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment