Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
PRRT
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
26
Issues
26
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LARN
PRRT
Commits
20325523
Commit
20325523
authored
Sep 05, 2018
by
Kai Vogelgesang
Committed by
rna
Sep 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add consistency checks to PrrtCodingConfiguration_create
parent
dafefe33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
prrt/proto/types/codingParams.c
prrt/proto/types/codingParams.c
+22
-1
No files found.
prrt/proto/types/codingParams.c
View file @
20325523
...
...
@@ -6,11 +6,32 @@
PrrtCodingConfiguration
*
PrrtCodingConfiguration_create
(
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
)
{
if
(
n
<
k
)
{
PERROR
(
"Invalid parameters: n must be greater or equal k.%s"
,
""
);
return
NULL
;
}
uint8_t
r
=
n
-
k
;
if
((
r
>
0
)
&&
(
n_cycle
==
NULL
))
{
PERROR
(
"Invalid parameters: n_cycle cannot be NULL if (n-k) != 0.%s"
,
""
);
return
NULL
;
}
uint8_t
sum
=
0
;
for
(
int
i
=
0
;
i
<
c
;
++
i
)
{
sum
+=
n_cycle
[
i
];
}
if
(
sum
!=
r
)
{
PERROR
(
"Invalid parameters: The elements in n_cycle must sum up to n-k.%s"
,
""
);
return
NULL
;
}
PrrtCodingConfiguration
*
cc
=
calloc
(
1
,
sizeof
(
PrrtCodingConfiguration
));
check_mem
(
cc
);
cc
->
k
=
k
;
cc
->
n
=
n
;
cc
->
r
=
cc
->
n
-
cc
->
k
;
cc
->
r
=
r
;
cc
->
c
=
c
;
if
(
n_cycle
!=
NULL
)
{
cc
->
n_cycle
=
(
uint8_t
*
)
realloc
(
cc
->
n_cycle
,
cc
->
c
*
sizeof
(
int8_t
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment