Commit 11c8aed3 authored by Brice Videau's avatar Brice Videau

Added API for user provided iterators.

parent 94c83320
...@@ -1538,6 +1538,21 @@ error: ...@@ -1538,6 +1538,21 @@ error:
return NULL; return NULL;
} }
excit_t excit_alloc_user(const struct excit_func_table_s *functions)
{
excit_t it;
it = malloc(sizeof(const struct excit_s));
if (!it)
return NULL;
ALLOC_EXCIT(it, (*functions));
it->type = EXCIT_USER;
return it;
error:
free(it);
return NULL;
}
excit_t excit_dup(excit_t it) excit_t excit_dup(excit_t it)
{ {
excit_t result = NULL; excit_t result = NULL;
...@@ -1559,10 +1574,13 @@ error: ...@@ -1559,10 +1574,13 @@ error:
void excit_free(excit_t it) void excit_free(excit_t it)
{ {
if (!it || !it->functions) if (!it)
return; return;
if (!it->functions)
goto error;
if (it->functions->free) if (it->functions->free)
it->functions->free(it); it->functions->free(it);
error:
free(it); free(it);
} }
......
...@@ -8,6 +8,7 @@ enum excit_type_e { ...@@ -8,6 +8,7 @@ enum excit_type_e {
EXCIT_HILBERT2D, EXCIT_HILBERT2D,
EXCIT_PRODUCT, EXCIT_PRODUCT,
EXCIT_SLICE, EXCIT_SLICE,
EXCIT_USER,
EXCIT_TYPE_MAX EXCIT_TYPE_MAX
}; };
...@@ -45,6 +46,7 @@ struct excit_func_table_s { ...@@ -45,6 +46,7 @@ struct excit_func_table_s {
}; };
excit_t excit_alloc(enum excit_type_e type); excit_t excit_alloc(enum excit_type_e type);
excit_t excit_alloc_user(const struct excit_func_table_s *functions);
excit_t excit_dup(const excit_t it); excit_t excit_dup(const excit_t it);
void excit_free(excit_t it); void excit_free(excit_t it);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment