diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
| commit | dd27c3530432ea0b09f01e604bf577f31d8ef841 (patch) | |
| tree | bbf86cf81a78f0ff0b07f31f1c390db473f26fd3 /lib/lvgl/src/misc/lv_utils.c | |
| parent | 6fd588e970470b15936187980829916d0dbe77bb (diff) | |
| download | tangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz | |
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/src/misc/lv_utils.c')
| m--------- | lib/lvgl | 0 | ||||
| -rw-r--r-- | lib/lvgl/src/misc/lv_utils.c | 79 |
2 files changed, 79 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 -Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a diff --git a/lib/lvgl/src/misc/lv_utils.c b/lib/lvgl/src/misc/lv_utils.c new file mode 100644 index 00000000..e17a231d --- /dev/null +++ b/lib/lvgl/src/misc/lv_utils.c @@ -0,0 +1,79 @@ +/** + * @file lv_utils.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include <stddef.h> + +#include "lv_utils.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** Searches base[0] to base[n - 1] for an item that matches *key. + * + * @note The function cmp must return negative if its first + * argument (the search key) is less than its second (a table entry), + * zero if equal, and positive if greater. + * + * @note Items in the array must be in ascending order. + * + * @param key Pointer to item being searched for + * @param base Pointer to first element to search + * @param n Number of elements + * @param size Size of each element + * @param cmp Pointer to comparison function (see #unicode_list_compare as a comparison function + * example) + * + * @return a pointer to a matching item, or NULL if none exists. + */ +void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, + int32_t (*cmp)(const void * pRef, const void * pElement)) +{ + const char * middle; + int32_t c; + + for(middle = base; n != 0;) { + middle += (n / 2) * size; + if((c = (*cmp)(key, middle)) > 0) { + n = (n / 2) - ((n & 1) == 0); + base = (middle += size); + } + else if(c < 0) { + n /= 2; + middle = base; + } + else { + return (char *)middle; + } + } + return NULL; +} + +/********************** + * STATIC FUNCTIONS + **********************/ |
