kmod/shared/array.h
Tobias Stoeckmann 6ef3643d0a shared: switch array API to size_t
The position in array_remove_at could be theoretically larger
than unsigned int. Switch to size_t to stay in sync with all
other such arguments in array context.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/68
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-08-16 00:00:00 -05:00

23 lines
645 B
C

#pragma once
#include <stddef.h>
/*
* Declaration of struct array is in header because we may want to embed the
* structure into another, so we need to know its size
*/
struct array {
void **array;
size_t count;
size_t total;
size_t step;
};
void array_init(struct array *array, size_t step);
int array_append(struct array *array, const void *element);
int array_append_unique(struct array *array, const void *element);
void array_pop(struct array *array);
void array_free_array(struct array *array);
void array_sort(struct array *array, int (*cmp)(const void *a, const void *b));
int array_remove_at(struct array *array, size_t pos);