diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:03:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:03:56 +0000 |
commit | 18da3ffcd7f3c8a0c5f790c801b5813503c2273d (patch) | |
tree | 84caf98dc5cef3d123c56ba12e35fd67026e0693 /shared/array.h | |
parent | Initial commit. (diff) | |
download | kmod-18da3ffcd7f3c8a0c5f790c801b5813503c2273d.tar.xz kmod-18da3ffcd7f3c8a0c5f790c801b5813503c2273d.zip |
Adding upstream version 31+20240202.upstream/31+20240202
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | shared/array.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/array.h b/shared/array.h new file mode 100644 index 0000000..b88482f --- /dev/null +++ b/shared/array.h @@ -0,0 +1,22 @@ +#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, unsigned int pos); |