star-uniq

Filter out repeated triangles
git clone git://git.meso-star.fr/star-uniq.git
Log | Files | Refs | README | LICENSE

commit 8201843bb76e1de0169eebe0b40b3850d421c908
parent 4b0f9c98f21a083afedee6450cbe125e731836aa
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 22 May 2025 10:24:38 +0200

Simplify the suniq_create profile

Grouping the input arguments in a single structure was a bad idea:
there's only one member variable, whose definition is optional. And
there's no reason to think that other variables will be needed in the
near future: a logger is unnecessary and so is library verbosity
control.

Consequently, the memory allocator is now directly submitted as an input
argument.

Diffstat:
Msrc/suniq.c | 12++++++------
Msrc/suniq.h | 9+--------
2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/suniq.c b/src/suniq.c @@ -247,20 +247,20 @@ release_suniq(ref_T* ref) * Exported functions ******************************************************************************/ res_T -suniq_create(const struct suniq_create_args* args, struct suniq** out_suniq) +suniq_create(struct mem_allocator* allocator, struct suniq** out_suniq) { - struct mem_allocator* allocator = NULL; + struct mem_allocator* mem_allocator = NULL; struct suniq* suniq = NULL; res_T res = RES_OK; - if(!args || !out_suniq) { res = RES_BAD_ARG; goto error; } + if(!out_suniq) { res = RES_BAD_ARG; goto error; } - allocator = args->allocator ? args->allocator : &mem_default_allocator; - suniq = MEM_CALLOC(allocator, 1, sizeof(*suniq)); + mem_allocator = allocator ? allocator : &mem_default_allocator; + suniq = MEM_CALLOC(mem_allocator, 1, sizeof(*suniq)); if(!suniq) { res = RES_MEM_ERR; goto error; } ref_init(&suniq->ref); - suniq->allocator = allocator; + suniq->allocator = mem_allocator; htable_key2itri_init(suniq->allocator, &suniq->key2itri); htable_pos2ivtx_init(suniq->allocator, &suniq->pos2ivtx); darray_size_t_init(suniq->allocator, &suniq->indices); diff --git a/src/suniq.h b/src/suniq.h @@ -37,13 +37,6 @@ struct logger; struct mem_allocator; -struct suniq_create_args { - struct mem_allocator* allocator; /* NULL <=> use default allocator */ -}; -#define SUNIQ_CREATE_ARGS_DEFAULT__ {NULL} -static const struct suniq_create_args SUNIQ_CREATE_ARGS_DEFAULT = - SUNIQ_CREATE_ARGS_DEFAULT__; - struct suniq_triangle { double vertices[3][3]; }; @@ -66,7 +59,7 @@ BEGIN_DECLS SUNIQ_API res_T suniq_create - (const struct suniq_create_args* args, + (struct mem_allocator* allocator, /* NULL <=> use default allocator */ struct suniq** suniq); SUNIQ_API res_T