Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
excit
Commits
64d5e7a2
Commit
64d5e7a2
authored
Jan 10, 2019
by
Nicolas Denoyelle
Browse files
checkpatch
parent
8ea0f2a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tleaf.c
View file @
64d5e7a2
...
...
@@ -8,8 +8,7 @@ static int tleaf_init_with_it(excit_t it,
const
ssize_t
*
arities
,
const
enum
tleaf_it_policy_e
policy
,
const
ssize_t
*
user_policy
,
excit_t
levels
,
excit_t
levels_inverse
);
excit_t
levels
,
excit_t
levels_inverse
);
static
int
tleaf_it_alloc
(
excit_t
it
)
{
...
...
@@ -40,12 +39,12 @@ static void tleaf_it_free(excit_t it)
excit_free
(
data_it
->
levels_inverse
);
}
static
int
tleaf_it_size
(
const
excit_t
it
,
ssize_t
*
size
)
{
struct
tleaf_it_s
*
data_it
=
it
->
data
;
ssize_t
i
,
s
=
1
;
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
)
ssize_t
i
,
s
=
1
;
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
)
s
*=
data_it
->
arities
[
i
];
*
size
=
data_it
->
depth
?
s
:
0
;
return
EXCIT_SUCCESS
;
...
...
@@ -54,6 +53,7 @@ static int tleaf_it_size(const excit_t it, ssize_t *size)
static
int
tleaf_it_rewind
(
excit_t
it
)
{
struct
tleaf_it_s
*
data_it
=
it
->
data
;
return
excit_rewind
(
data_it
->
levels
);
}
...
...
@@ -74,8 +74,8 @@ static int tleaf_it_copy(excit_t dst_it, const excit_t src_it)
}
/* dst is not initialized (anymore) */
excit_t
levels
=
excit_dup
(
src
->
levels
);
excit_t
levels
=
excit_dup
(
src
->
levels
);
if
(
levels
==
NULL
)
{
err
=
-
EXCIT_ENOMEM
;
goto
error
;
...
...
@@ -88,9 +88,9 @@ static int tleaf_it_copy(excit_t dst_it, const excit_t src_it)
goto
error_with_levels
;
}
err
=
tleaf_init_with_it
(
dst_it
,
src
->
depth
+
1
,
src
->
arities
,
TLEAF_POLICY_USER
,
src
->
order
,
levels
,
levels_inverse
);
TLEAF_POLICY_USER
,
src
->
order
,
levels
,
levels_inverse
);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error_with_levels_inverse
;
...
...
@@ -107,12 +107,14 @@ error:
static
int
tleaf_it_pos
(
const
excit_t
it
,
ssize_t
*
value
)
{
struct
tleaf_it_s
*
data_it
=
it
->
data
;
return
excit_pos
(
data_it
->
levels
,
value
);
}
static
ssize_t
tleaf_it_value
(
struct
tleaf_it_s
*
it
)
{
ssize_t
i
,
acc
=
1
,
val
=
0
;
for
(
i
=
0
;
i
<
it
->
depth
;
i
++
)
{
val
+=
acc
*
it
->
buf
[
i
];
acc
*=
it
->
arities
[
it
->
order
[
i
]];
...
...
@@ -161,8 +163,9 @@ int tleaf_it_rank(const excit_t it, const ssize_t *indexes, ssize_t *n)
if
(
err
!=
EXCIT_SUCCESS
)
return
err
;
ssize_t
i
,
acc
=
1
,
val
=
0
;
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
)
{
val
+=
acc
*
data_it
->
buf
[
i
];
acc
*=
data_it
->
arities
[
data_it
->
order_inverse
[
i
]];
...
...
@@ -172,16 +175,18 @@ int tleaf_it_rank(const excit_t it, const ssize_t *indexes, ssize_t *n)
return
EXCIT_SUCCESS
;
}
static
int
tleaf_add_level
(
excit_t
levels
,
const
ssize_t
arity
){
excit_t
level
=
excit_alloc
(
EXCIT_RANGE
);
if
(
level
==
NULL
)
return
-
EXCIT_ENOMEM
;
static
int
tleaf_add_level
(
excit_t
levels
,
const
ssize_t
arity
)
{
excit_t
level
=
excit_alloc
(
EXCIT_RANGE
);
if
(
level
==
NULL
)
return
-
EXCIT_ENOMEM
;
int
err
=
excit_range_init
(
level
,
0
,
arity
-
1
,
1
);
int
err
;
err
=
excit_range_init
(
level
,
0
,
arity
-
1
,
1
);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error
;
err
=
excit_product_add
(
levels
,
level
);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error
;
...
...
@@ -196,8 +201,7 @@ static int tleaf_init_with_it(excit_t it,
const
ssize_t
*
arities
,
const
enum
tleaf_it_policy_e
policy
,
const
ssize_t
*
user_policy
,
excit_t
levels
,
excit_t
levels_inverse
)
excit_t
levels
,
excit_t
levels_inverse
)
{
if
(
it
==
NULL
||
it
->
data
==
NULL
)
return
-
EXCIT_EINVAL
;
...
...
@@ -233,7 +237,7 @@ static int tleaf_init_with_it(excit_t it,
/* Set order inverse */
data_it
->
order_inverse
=
malloc
(
sizeof
(
*
data_it
->
order_inverse
)
*
data_it
->
depth
);
malloc
(
sizeof
(
*
data_it
->
order_inverse
)
*
data_it
->
depth
);
if
(
data_it
->
order_inverse
==
NULL
)
{
err
=
-
EXCIT_ENOMEM
;
goto
error_with_order
;
...
...
@@ -264,25 +268,31 @@ static int tleaf_init_with_it(excit_t it,
err
=
-
EXCIT_ENOMEM
;
goto
error_with_buf
;
}
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
){
err
=
tleaf_add_level
(
levels
,
data_it
->
arities
[
data_it
->
order
[
i
]]);
if
(
err
!=
EXCIT_SUCCESS
)
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
)
{
ssize_t
l
=
data_it
->
order
[
i
];
err
=
tleaf_add_level
(
levels
,
data_it
->
arities
[
l
]);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error_with_levels
;
}
}
else
{
data_it
->
levels
=
levels
;
}
if
(
levels_inverse
==
NULL
)
{
data_it
->
levels_inverse
=
excit_alloc
(
EXCIT_PRODUCT
);
if
(
data_it
->
levels_inverse
==
NULL
)
{
err
=
-
EXCIT_ENOMEM
;
goto
error_with_levels
;
}
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
){
err
=
tleaf_add_level
(
levels_inverse
,
data_it
->
arities
[
data_it
->
order_inverse
[
i
]]);
if
(
err
!=
EXCIT_SUCCESS
)
for
(
i
=
0
;
i
<
data_it
->
depth
;
i
++
)
{
ssize_t
l
=
data_it
->
order_inverse
[
i
];
err
=
tleaf_add_level
(
levels_inverse
,
data_it
->
arities
[
l
]);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error_with_levels_inverse
;
}
}
else
{
...
...
@@ -293,7 +303,7 @@ static int tleaf_init_with_it(excit_t it,
error_with_levels_inverse:
excit_free
(
data_it
->
levels_inverse
);
data_it
->
levels_inverse
=
NULL
;
data_it
->
levels_inverse
=
NULL
;
error_with_levels:
excit_free
(
data_it
->
levels
);
data_it
->
levels
=
NULL
;
...
...
@@ -323,13 +333,16 @@ int excit_tleaf_init(excit_t it,
NULL
,
NULL
);
}
int
tleaf_split_levels
(
excit_t
levels
,
const
ssize_t
depth
,
const
ssize_t
n
,
excit_t
**
out
){
*
out
=
malloc
(
sizeof
(
**
out
)
*
n
);
int
tleaf_split_levels
(
excit_t
levels
,
const
ssize_t
depth
,
const
ssize_t
n
,
excit_t
**
out
)
{
*
out
=
malloc
(
sizeof
(
**
out
)
*
n
);
if
(
*
out
==
NULL
)
return
-
EXCIT_ENOMEM
;
int
err
=
excit_product_split_dim
(
levels
,
depth
,
n
,
*
out
);
if
(
err
!=
EXCIT_SUCCESS
){
if
(
err
!=
EXCIT_SUCCESS
)
{
free
(
*
out
);
*
out
=
NULL
;
return
err
;
...
...
@@ -348,17 +361,22 @@ int tleaf_it_split(const excit_t it, const ssize_t depth,
return
-
EXCIT_EINVAL
;
struct
tleaf_it_s
*
data_it
=
it
->
data
;
if
(
data_it
->
arities
[
data_it
->
order
[
depth
]]
%
n
!=
0
)
return
-
EXCIT_EINVAL
;
int
err
;
excit_t
*
levels
,
*
levels_inverse
;
err
=
tleaf_split_levels
(
data_it
->
levels
,
data_it
->
order
[
depth
],
n
,
&
levels
);
if
(
err
!=
EXCIT_SUCCESS
)
err
=
tleaf_split_levels
(
data_it
->
levels
,
data_it
->
order
[
depth
],
n
,
&
levels
);
if
(
err
!=
EXCIT_SUCCESS
)
return
err
;
err
=
tleaf_split_levels
(
data_it
->
levels_inverse
,
data_it
->
order_inverse
[
depth
],
n
,
&
levels_inverse
);
err
=
tleaf_split_levels
(
data_it
->
levels_inverse
,
data_it
->
order_inverse
[
depth
],
n
,
&
levels_inverse
);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error_with_levels
;
...
...
@@ -367,7 +385,8 @@ int tleaf_it_split(const excit_t it, const ssize_t depth,
data_it
->
depth
+
1
,
data_it
->
arities
,
TLEAF_POLICY_USER
,
data_it
->
order
,
levels
[
i
],
levels_inverse
[
i
]);
data_it
->
order
,
levels
[
i
],
levels_inverse
[
i
]);
if
(
err
!=
EXCIT_SUCCESS
)
goto
error_with_levels_inverse
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment