Commit 024652bd authored by Swann Perarnau's avatar Swann Perarnau

[refactor] convert tiling iterator to new create

Last bit of API lacking consistency.
parent 90b8f8bb
Pipeline #6882 passed with stages
in 10 minutes and 9 seconds
......@@ -160,8 +160,10 @@ struct aml_tiling_ops {
int flags);
int (*init_iterator)(struct aml_tiling_data *tiling,
struct aml_tiling_iterator *iterator, int flags);
int (*destroy_iterator)(struct aml_tiling_data *tiling,
int (*fini_iterator)(struct aml_tiling_data *tiling,
struct aml_tiling_iterator *iterator);
int (*destroy_iterator)(struct aml_tiling_data *tiling,
struct aml_tiling_iterator **iterator);
int (*tileid)(const struct aml_tiling_data *tiling, va_list coords);
size_t (*tilesize)(const struct aml_tiling_data *tiling, int tileid);
void* (*tilestart)(const struct aml_tiling_data *tiling,
......@@ -237,14 +239,22 @@ int aml_tiling_create_iterator(struct aml_tiling *tiling,
*/
int aml_tiling_init_iterator(struct aml_tiling *tiling,
struct aml_tiling_iterator *iterator, int flags);
/*
* Finalize an initialized tiling iterator.
* "tiling": an initialized tiling structure.
* "iterator": an initialized tiling iterator structure.
*/
void aml_tiling_fini_iterator(struct aml_tiling *tiling,
struct aml_tiling_iterator *iterator);
/*
* Tears down an initialized tiling iterator.
* "tiling": an initialized tiling structure.
* "iterator": an initialized tiling iterator structure.
* Returns 0 if successful; an error code otherwise.
*/
int aml_tiling_destroy_iterator(struct aml_tiling *tiling,
struct aml_tiling_iterator *iterator);
void aml_tiling_destroy_iterator(struct aml_tiling *tiling,
struct aml_tiling_iterator **iterator);
struct aml_tiling_iterator_ops {
int (*reset)(struct aml_tiling_iterator_data *iterator);
......
......@@ -108,10 +108,18 @@ int aml_tiling_init_iterator(struct aml_tiling *t,
return t->ops->init_iterator(t->data, it, flags);
}
int aml_tiling_destroy_iterator(struct aml_tiling *t,
void aml_tiling_fini_iterator(struct aml_tiling *t,
struct aml_tiling_iterator *it)
{
assert(t != NULL);
assert(it != NULL);
return t->ops->destroy_iterator(t->data, it);
t->ops->fini_iterator(t->data, it);
}
void aml_tiling_destroy_iterator(struct aml_tiling *t,
struct aml_tiling_iterator **it)
{
assert(t != NULL);
assert(it != NULL);
t->ops->destroy_iterator(t->data, it);
}
......@@ -133,15 +133,23 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t,
return 0;
}
int aml_tiling_1d_destroy_iterator(struct aml_tiling_data *t,
int aml_tiling_1d_fini_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it)
{
return 0;
}
int aml_tiling_1d_destroy_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator **it)
{
free(*it);
return 0;
}
struct aml_tiling_ops aml_tiling_1d_ops = {
aml_tiling_1d_create_iterator,
aml_tiling_1d_init_iterator,
aml_tiling_1d_fini_iterator,
aml_tiling_1d_destroy_iterator,
aml_tiling_1d_tileid,
aml_tiling_1d_tilesize,
......
......@@ -153,16 +153,23 @@ int aml_tiling_2d_create_iterator(struct aml_tiling_data *t,
return 0;
}
int aml_tiling_2d_destroy_iterator(struct aml_tiling_data *t,
int aml_tiling_2d_fini_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it)
{
return 0;
}
int aml_tiling_2d_destroy_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator **it)
{
free(*it);
return 0;
}
struct aml_tiling_ops aml_tiling_2d_rowmajor_ops = {
aml_tiling_2d_create_iterator,
aml_tiling_2d_init_iterator,
aml_tiling_2d_fini_iterator,
aml_tiling_2d_destroy_iterator,
aml_tiling_2d_rowmajor_tileid,
aml_tiling_2d_tilesize,
......@@ -173,6 +180,7 @@ struct aml_tiling_ops aml_tiling_2d_rowmajor_ops = {
struct aml_tiling_ops aml_tiling_2d_colmajor_ops = {
aml_tiling_2d_create_iterator,
aml_tiling_2d_init_iterator,
aml_tiling_2d_fini_iterator,
aml_tiling_2d_destroy_iterator,
aml_tiling_2d_colmajor_tileid,
aml_tiling_2d_tilesize,
......
......@@ -63,9 +63,8 @@ int main(int argc, char *argv[])
doit(&b, &itb);
/* delete the iterators */
aml_tiling_destroy_iterator(a, ita);
aml_tiling_destroy_iterator(&b, &itb);
free(ita);
aml_tiling_destroy_iterator(a, &ita);
aml_tiling_fini_iterator(&b, &itb);
/* delete the tilings */
......
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