mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-23 10:53:40 +08:00
6ef3643d0a
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>
23 lines
645 B
C
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);
|