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
136a24ee
Commit
136a24ee
authored
Nov 08, 2018
by
Brice Videau
Browse files
Change return codes.
parent
31e5d22d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/excit.c
View file @
136a24ee
#include
<errno.h>
#include
<stdlib.h>
#include
<excit.h>
...
...
@@ -37,13 +36,13 @@ static int slice_iterator_alloc(excit_t data)
{
data
->
data
=
malloc
(
sizeof
(
struct
slice_iterator_s
));
if
(
!
data
->
data
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
struct
slice_iterator_s
*
iterator
=
(
struct
slice_iterator_s
*
)
data
->
data
;
iterator
->
src
=
NULL
;
iterator
->
indexer
=
NULL
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
void
slice_iterator_free
(
excit_t
data
)
...
...
@@ -64,13 +63,13 @@ static int slice_iterator_copy(excit_t dst, const excit_t src)
result
->
src
=
excit_dup
(
iterator
->
src
);
if
(
!
result
->
src
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
result
->
indexer
=
excit_dup
(
iterator
->
indexer
);
if
(
!
result
->
indexer
)
{
excit_free
(
iterator
->
src
);
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
slice_iterator_next
(
excit_t
data
,
excit_index_t
*
indexes
)
...
...
@@ -159,7 +158,7 @@ static int slice_iterator_split(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
!
results
)
return
0
;
return
EXCIT_SUCCESS
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
excit_t
tmp
;
excit_t
tmp2
;
...
...
@@ -168,13 +167,13 @@ static int slice_iterator_split(const excit_t data, excit_index_t n,
results
[
i
]
=
excit_alloc
(
EXCIT_SLICE
);
if
(
!
results
[
i
])
{
excit_free
(
tmp
);
err
=
-
ENOMEM
;
err
=
-
EXCIT_
ENOMEM
;
goto
error
;
}
tmp2
=
excit_dup
(
iterator
->
src
);
if
(
!
tmp2
)
{
excit_free
(
tmp
);
err
=
-
ENOMEM
;
err
=
-
EXCIT_
ENOMEM
;
goto
error
;
}
err
=
excit_slice_init
(
results
[
i
],
tmp
,
tmp2
);
...
...
@@ -184,7 +183,7 @@ static int slice_iterator_split(const excit_t data, excit_index_t n,
goto
error
;
}
}
return
0
;
return
EXCIT_SUCCESS
;
error:
for
(
int
i
=
0
;
i
<
n
;
i
++
)
excit_free
(
results
[
i
]);
...
...
@@ -210,7 +209,7 @@ int excit_slice_init(excit_t iterator, excit_t src,
{
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_SLICE
||
!
src
||
!
indexer
||
indexer
->
dimension
!=
1
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
struct
slice_iterator_s
*
it
=
(
struct
slice_iterator_s
*
)
iterator
->
data
;
excit_index_t
size_src
;
...
...
@@ -223,11 +222,11 @@ int excit_slice_init(excit_t iterator, excit_t src,
if
(
err
)
return
err
;
if
(
size_indexer
>
size_src
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
it
->
src
=
src
;
it
->
indexer
=
indexer
;
iterator
->
dimension
=
src
->
dimension
;
return
0
;
return
EXCIT_SUCCESS
;
}
/*--------------------------------------------------------------------*/
...
...
@@ -241,13 +240,13 @@ static int product_iterator_alloc(excit_t data)
{
data
->
data
=
malloc
(
sizeof
(
struct
product_iterator_s
));
if
(
!
data
->
data
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
struct
product_iterator_s
*
iterator
=
(
struct
product_iterator_s
*
)
data
->
data
;
iterator
->
count
=
0
;
iterator
->
iterators
=
NULL
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
void
product_iterator_free
(
excit_t
data
)
...
...
@@ -272,7 +271,7 @@ static int product_iterator_copy(excit_t dst, const excit_t src)
result
->
iterators
=
(
excit_t
*
)
malloc
(
iterator
->
count
*
sizeof
(
excit_t
));
if
(
!
result
->
iterators
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
excit_index_t
i
;
for
(
i
=
0
;
i
<
iterator
->
count
;
i
++
)
{
...
...
@@ -283,14 +282,14 @@ static int product_iterator_copy(excit_t dst, const excit_t src)
}
}
result
->
count
=
iterator
->
count
;
return
0
;
return
EXCIT_SUCCESS
;
error:
while
(
i
>=
0
)
{
free
(
result
->
iterators
[
i
]);
i
--
;
}
free
(
result
->
iterators
);
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
}
static
int
product_iterator_rewind
(
excit_t
data
)
...
...
@@ -304,7 +303,7 @@ static int product_iterator_rewind(excit_t data)
if
(
err
)
return
err
;
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
product_iterator_size
(
const
excit_t
data
,
...
...
@@ -315,7 +314,7 @@ static int product_iterator_size(const excit_t data,
excit_index_t
tmp_size
=
0
;
if
(
!
size
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
if
(
iterator
->
count
==
0
)
*
size
=
0
;
else
{
...
...
@@ -331,7 +330,7 @@ static int product_iterator_size(const excit_t data,
*
size
*=
tmp_size
;
}
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
product_iterator_nth
(
const
excit_t
data
,
excit_index_t
n
,
...
...
@@ -343,7 +342,7 @@ static int product_iterator_nth(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
n
<
0
||
n
>=
size
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
const
struct
product_iterator_s
*
iterator
=
(
const
struct
product_iterator_s
*
)
data
->
data
;
...
...
@@ -364,7 +363,7 @@ static int product_iterator_nth(const excit_t data, excit_index_t n,
n
/=
subsize
;
}
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
product_iterator_n
(
const
excit_t
data
,
...
...
@@ -375,7 +374,7 @@ static int product_iterator_n(const excit_t data,
(
const
struct
product_iterator_s
*
)
data
->
data
;
if
(
iterator
->
count
==
0
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
excit_index_t
offset
=
0
;
excit_index_t
product
=
0
;
excit_index_t
inner_n
;
...
...
@@ -396,7 +395,7 @@ static int product_iterator_n(const excit_t data,
}
if
(
n
)
*
n
=
product
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
product_iterator_pos
(
const
excit_t
data
,
excit_index_t
*
n
)
...
...
@@ -405,7 +404,7 @@ static int product_iterator_pos(const excit_t data, excit_index_t *n)
(
const
struct
product_iterator_s
*
)
data
->
data
;
if
(
iterator
->
count
==
0
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
excit_index_t
product
=
0
;
excit_index_t
inner_n
;
excit_index_t
subsize
;
...
...
@@ -423,7 +422,7 @@ static int product_iterator_pos(const excit_t data, excit_index_t *n)
}
if
(
n
)
*
n
=
product
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
inline
int
product_iterator_peeknext_helper
(
excit_t
data
,
...
...
@@ -439,7 +438,7 @@ static inline int product_iterator_peeknext_helper(excit_t data,
excit_index_t
offset
=
data
->
dimension
;
if
(
iterator
->
count
==
0
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
looped
=
next
;
for
(
i
=
iterator
->
count
-
1
;
i
>
0
;
i
--
)
{
if
(
indexes
)
{
...
...
@@ -469,7 +468,7 @@ static inline int product_iterator_peeknext_helper(excit_t data,
err
=
excit_peek
(
iterator
->
iterators
[
0
],
next_indexes
);
if
(
err
)
return
err
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
product_iterator_peek
(
const
excit_t
data
,
...
...
@@ -492,13 +491,13 @@ static int product_iterator_split(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
size
<
n
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
if
(
!
results
)
return
0
;
return
EXCIT_SUCCESS
;
excit_t
range
=
excit_alloc
(
EXCIT_RANGE
);
if
(
!
range
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
err
=
excit_range_init
(
range
,
0
,
size
-
1
,
1
);
if
(
err
)
goto
error1
;
...
...
@@ -524,7 +523,7 @@ static int product_iterator_split(const excit_t data, excit_index_t n,
}
}
excit_free
(
range
);
return
0
;
return
EXCIT_SUCCESS
;
error2:
for
(
int
i
=
0
;
i
<
n
;
i
++
)
excit_free
(
results
[
i
]);
...
...
@@ -537,9 +536,9 @@ int excit_product_count(const excit_t iterator,
excit_index_t
*
count
)
{
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_PRODUCT
||
!
count
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
*
count
=
((
struct
product_iterator_s
*
)
iterator
->
data
)
->
count
;
return
0
;
return
EXCIT_SUCCESS
;
}
int
excit_product_split_dim
(
const
excit_t
iterator
,
...
...
@@ -547,16 +546,16 @@ int excit_product_split_dim(const excit_t iterator,
excit_t
*
results
)
{
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_PRODUCT
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
if
(
n
<=
0
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
excit_index_t
count
;
int
err
=
excit_product_count
(
iterator
,
&
count
);
if
(
err
)
return
err
;
if
(
dim
>=
count
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
struct
product_iterator_s
*
product_iterator
=
(
struct
product_iterator_s
*
)
iterator
->
data
;
...
...
@@ -564,14 +563,14 @@ int excit_product_split_dim(const excit_t iterator,
if
(
err
)
return
err
;
if
(
!
results
)
return
0
;
return
EXCIT_SUCCESS
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
excit_t
tmp
=
results
[
i
];
results
[
i
]
=
excit_dup
(
iterator
);
if
(
!
tmp
)
{
excit_free
(
tmp
);
err
=
-
ENOMEM
;
err
=
-
EXCIT_
ENOMEM
;
goto
error
;
}
struct
product_iterator_s
*
new_product_iterator
=
...
...
@@ -579,7 +578,7 @@ int excit_product_split_dim(const excit_t iterator,
excit_free
(
new_product_iterator
->
iterators
[
dim
]);
new_product_iterator
->
iterators
[
dim
]
=
tmp
;
}
return
0
;
return
EXCIT_SUCCESS
;
error:
for
(
int
i
=
0
;
i
<
n
;
i
++
)
excit_free
(
results
[
i
]);
...
...
@@ -592,20 +591,20 @@ int excit_product_add_copy(excit_t iterator, excit_t added_iterator)
excit_t
copy
=
excit_dup
(
added_iterator
);
if
(
!
copy
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
err
=
excit_product_add
(
iterator
,
copy
);
if
(
err
)
{
excit_free
(
added_iterator
);
return
err
;
}
return
0
;
return
EXCIT_SUCCESS
;
}
int
excit_product_add
(
excit_t
iterator
,
excit_t
added_iterator
)
{
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_PRODUCT
||
!
iterator
->
data
||
!
added_iterator
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
struct
product_iterator_s
*
product_iterator
=
(
struct
product_iterator_s
*
)
iterator
->
data
;
...
...
@@ -615,12 +614,12 @@ int excit_product_add(excit_t iterator, excit_t added_iterator)
(
excit_t
*
)
realloc
(
product_iterator
->
iterators
,
mew_count
*
sizeof
(
excit_t
));
if
(
!
new_its
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
product_iterator
->
iterators
=
new_its
;
product_iterator
->
iterators
[
product_iterator
->
count
]
=
added_iterator
;
product_iterator
->
count
=
mew_count
;
iterator
->
dimension
+=
added_iterator
->
dimension
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
const
struct
excit_func_table_s
excit_product_func_table
=
{
...
...
@@ -682,7 +681,7 @@ static int cons_iterator_alloc(excit_t data)
{
data
->
data
=
malloc
(
sizeof
(
struct
cons_iterator_s
));
if
(
!
data
->
data
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
struct
cons_iterator_s
*
iterator
=
(
struct
cons_iterator_s
*
)
data
->
data
;
...
...
@@ -693,7 +692,7 @@ static int cons_iterator_alloc(excit_t data)
iterator
->
fifo
.
end
=
-
1
;
iterator
->
fifo
.
size
=
0
;
iterator
->
fifo
.
buffer
=
NULL
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
void
cons_iterator_free
(
excit_t
data
)
...
...
@@ -714,7 +713,7 @@ static int cons_iterator_copy(excit_t ddst, const excit_t dsrc)
excit_t
copy
=
excit_dup
(
src
->
iterator
);
if
(
!
copy
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
dst
->
iterator
=
copy
;
dst
->
n
=
src
->
n
;
dst
->
fifo
.
length
=
src
->
fifo
.
length
;
...
...
@@ -726,11 +725,11 @@ static int cons_iterator_copy(excit_t ddst, const excit_t dsrc)
sizeof
(
excit_index_t
));
if
(
!
dst
->
fifo
.
buffer
)
{
excit_free
(
copy
);
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
}
for
(
int
i
=
0
;
i
<
dst
->
fifo
.
length
;
i
++
)
dst
->
fifo
.
buffer
[
i
]
=
src
->
fifo
.
buffer
[
i
];
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_size
(
const
excit_t
data
,
excit_index_t
*
size
)
...
...
@@ -743,7 +742,7 @@ static int cons_iterator_size(const excit_t data, excit_index_t *size)
if
(
err
)
return
err
;
*
size
=
tmp_size
-
(
iterator
->
n
-
1
);
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_split
(
const
excit_t
data
,
excit_index_t
n
,
...
...
@@ -755,13 +754,13 @@ static int cons_iterator_split(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
size
<
n
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
if
(
!
results
)
return
0
;
return
EXCIT_SUCCESS
;
excit_t
range
=
excit_alloc
(
EXCIT_RANGE
);
if
(
!
range
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
err
=
excit_range_init
(
range
,
0
,
size
-
1
,
1
);
if
(
err
)
goto
error1
;
...
...
@@ -789,7 +788,7 @@ static int cons_iterator_split(const excit_t data, excit_index_t n,
}
}
excit_free
(
range
);
return
0
;
return
EXCIT_SUCCESS
;
error2:
for
(;
i
>=
0
;
i
--
)
excit_free
(
results
[
i
]);
...
...
@@ -807,7 +806,7 @@ static int cons_iterator_nth(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
n
<
0
||
n
>=
size
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
const
struct
cons_iterator_s
*
iterator
=
(
const
struct
cons_iterator_s
*
)
data
->
data
;
int
dim
=
iterator
->
iterator
->
dimension
;
...
...
@@ -821,7 +820,7 @@ static int cons_iterator_nth(const excit_t data, excit_index_t n,
return
err
;
}
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_n
(
const
excit_t
data
,
...
...
@@ -844,12 +843,12 @@ static int cons_iterator_n(const excit_t data,
if
(
err
)
return
err
;
if
(
inner_n_tmp
!=
inner_n
+
1
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
inner_n
=
inner_n_tmp
;
}
if
(
n
)
*
n
=
inner_n
-
(
iterator
->
n
-
1
);
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_pos
(
const
excit_t
data
,
excit_index_t
*
n
)
...
...
@@ -863,7 +862,7 @@ static int cons_iterator_pos(const excit_t data, excit_index_t *n)
return
err
;
if
(
n
)
*
n
=
inner_n
-
(
iterator
->
n
-
1
);
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_peek
(
const
excit_t
data
,
...
...
@@ -883,7 +882,7 @@ static int cons_iterator_peek(const excit_t data,
err
=
excit_peek
(
iterator
->
iterator
,
NULL
);
if
(
err
)
return
err
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_next
(
excit_t
data
,
excit_index_t
*
indexes
)
...
...
@@ -905,7 +904,7 @@ static int cons_iterator_next(excit_t data, excit_index_t *indexes)
if
(
indexes
)
for
(
int
i
=
dim
*
(
n
-
1
);
i
<
dim
*
n
;
i
++
)
circular_fifo_add
(
&
iterator
->
fifo
,
indexes
[
i
]);
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
cons_iterator_rewind
(
excit_t
data
)
...
...
@@ -932,7 +931,7 @@ static int cons_iterator_rewind(excit_t data)
iterator
->
fifo
.
size
+=
iterator
->
iterator
->
dimension
;
iterator
->
fifo
.
end
+=
iterator
->
iterator
->
dimension
;
}
return
0
;
return
EXCIT_SUCCESS
;
}
int
excit_cons_init
(
excit_t
iterator
,
excit_t
src
,
...
...
@@ -942,12 +941,12 @@ int excit_cons_init(excit_t iterator, excit_t src,
int
err
;
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_CONS
||
!
src
||
n
<=
0
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
err
=
excit_size
(
src
,
&
src_size
);
if
(
err
)
return
err
;
if
(
src_size
<
n
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
struct
cons_iterator_s
*
cons_iterator
=
(
struct
cons_iterator_s
*
)
iterator
->
data
;
...
...
@@ -961,13 +960,13 @@ int excit_cons_init(excit_t iterator, excit_t src,
(
excit_index_t
*
)
malloc
(
cons_iterator
->
fifo
.
length
*
sizeof
(
excit_index_t
));
if
(
!
cons_iterator
->
fifo
.
buffer
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
err
=
cons_iterator_rewind
(
iterator
);
if
(
err
)
{
free
(
cons_iterator
->
fifo
.
buffer
);
return
err
;
}
return
0
;
return
EXCIT_SUCCESS
;
}
static
const
struct
excit_func_table_s
excit_cons_func_table
=
{
...
...
@@ -996,14 +995,14 @@ static int repeat_iterator_alloc(excit_t data)
{
data
->
data
=
malloc
(
sizeof
(
struct
repeat_iterator_s
));
if
(
!
data
->
data
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
struct
repeat_iterator_s
*
iterator
=
(
struct
repeat_iterator_s
*
)
data
->
data
;
iterator
->
iterator
=
NULL
;
iterator
->
n
=
0
;
iterator
->
counter
=
0
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
void
repeat_iterator_free
(
excit_t
data
)
...
...
@@ -1023,11 +1022,11 @@ static int repeat_iterator_copy(excit_t ddst, const excit_t dsrc)
excit_t
copy
=
excit_dup
(
src
->
iterator
);
if
(
!
copy
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
dst
->
iterator
=
copy
;
dst
->
n
=
src
->
n
;
dst
->
counter
=
src
->
counter
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
repeat_iterator_peek
(
const
excit_t
data
,
...
...
@@ -1061,7 +1060,7 @@ static int repeat_iterator_size(const excit_t data,
if
(
err
)
return
err
;
*
size
*=
iterator
->
n
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
repeat_iterator_rewind
(
excit_t
data
)
...
...
@@ -1082,7 +1081,7 @@ static int repeat_iterator_nth(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
n
<
0
||
n
>=
size
)
return
-
EDOM
;
return
-
EXCIT_
EDOM
;
const
struct
repeat_iterator_s
*
iterator
=
(
const
struct
repeat_iterator_s
*
)
data
->
data
;
...
...
@@ -1100,7 +1099,7 @@ static int repeat_iterator_pos(const excit_t data, excit_index_t *n)
return
err
;
if
(
n
)
*
n
=
inner_n
*
iterator
->
n
+
iterator
->
counter
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
repeat_iterator_split
(
const
excit_t
data
,
excit_index_t
n
,
...
...
@@ -1113,7 +1112,7 @@ static int repeat_iterator_split(const excit_t data, excit_index_t n,
if
(
err
)
return
err
;
if
(
!
results
)
return
0
;
return
EXCIT_SUCCESS
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
excit_t
tmp
;
...
...
@@ -1121,14 +1120,14 @@ static int repeat_iterator_split(const excit_t data, excit_index_t n,
results
[
i
]
=
excit_alloc
(
EXCIT_REPEAT
);
if
(
!
results
[
i
])
{
excit_free
(
tmp
);
err
=
-
ENOMEM
;
err
=
-
EXCIT_
ENOMEM
;
goto
error
;
}
err
=
excit_repeat_init
(
results
[
i
],
tmp
,
iterator
->
n
);
if
(
err
)
goto
error
;
}
return
0
;
return
EXCIT_SUCCESS
;
error:
for
(
int
i
=
0
;
i
<
n
;
i
++
)
excit_free
(
results
[
i
]);
...
...
@@ -1153,7 +1152,7 @@ int excit_repeat_init(excit_t iterator, excit_t src,
excit_index_t
n
)
{
if
(
!
iterator
||
iterator
->
type
!=
EXCIT_REPEAT
||
!
src
||
n
<=
0
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
struct
repeat_iterator_s
*
repeat_iterator
=
(
struct
repeat_iterator_s
*
)
iterator
->
data
;
excit_free
(
repeat_iterator
->
iterator
);
...
...
@@ -1161,7 +1160,7 @@ int excit_repeat_init(excit_t iterator, excit_t src,
repeat_iterator
->
iterator
=
src
;
repeat_iterator
->
n
=
n
;
repeat_iterator
->
counter
=
0
;
return
0
;
return
EXCIT_SUCCESS
;
}
/*--------------------------------------------------------------------*/
...
...
@@ -1229,13 +1228,13 @@ static int hilbert2d_iterator_alloc(excit_t data)
{
data
->
data
=
malloc
(
sizeof
(
struct
hilbert2d_iterator_s
));
if
(
!
data
->
data
)
return
-
ENOMEM
;
return
-
EXCIT_
ENOMEM
;
struct
hilbert2d_iterator_s
*
iterator
=
(
struct
hilbert2d_iterator_s
*
)
data
->
data
;
iterator
->
n
=
0
;
iterator
->
range_iterator
=
NULL
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
void
hilbert2d_iterator_free
(
excit_t
data
)
...
...
@@ -1256,10 +1255,10 @@ static int hilbert2d_iterator_copy(excit_t ddst, const excit_t dsrc)
excit_t
copy
=
excit_dup
(
src
->
range_iterator
);
if
(
!
copy
)
return
-
EINVAL
;
return
-
EXCIT_
EINVAL
;
dst
->
range_iterator
=
copy
;
dst
->
n
=
src
->
n
;
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
hilbert2d_iterator_rewind
(
excit_t
data
)
...
...
@@ -1283,7 +1282,7 @@ static int hilbert2d_iterator_peek(const excit_t data,
return
err
;
if
(
val
)
d2xy
(
iterator
->
n
,
d
,
val
,
val
+
1
);
return
0
;
return
EXCIT_SUCCESS
;
}
static
int
hilbert2d_iterator_next
(
excit_t
data
,
excit_index_t
*
val
)
...
...
@@ -1297,7 +1296,7 @@ static int hilbert2d_iterator_next(excit_t data, excit_index_t *val)
return
err
;
if
(
val
)