aboutsummaryrefslogtreecommitdiffstats
path: root/compressor.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-04-27 21:16:07 -0400
committerSam Anthony <sam@samanthony.xyz>2025-04-27 21:16:07 -0400
commit326dc9c305501655c5a10024f354ecaffa113a9e (patch)
treea5500239a3970234f4b6f0b6f7f82854b804e9cb /compressor.c
parent97523ee06ffba9ffd4578c016aa2a2b77662e090 (diff)
downloadvolute-326dc9c305501655c5a10024f354ecaffa113a9e.zip
rename index() to lsearch()
Diffstat (limited to 'compressor.c')
-rw-r--r--compressor.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/compressor.c b/compressor.c
index 0fdee78..b1a6020 100644
--- a/compressor.c
+++ b/compressor.c
@@ -23,7 +23,7 @@ static int load_point(const toml_table_t *tbl, const char *key, const char *flow
static int parse_flow(double val, const char *unit, Flow *flow);
static int parse_mass_flow(double val, const char *unit, Flow *flow);
static int parse_volume_flow(double val, const char *unit, Flow *flow);
-static int index(const void *key, const void *base, size_t n, size_t size, int (*cmp)(const void *keyval, const void *datum));
+static int lsearch(const void *key, const void *base, size_t n, size_t size, int (*cmp)(const void *keyval, const void *datum));
static int toml_filter(const struct dirent *de);
static int cmp_flow_unit(const void *key, const void *datum);
static void free_arr(void **arr, int n);
@@ -220,7 +220,7 @@ static int
parse_mass_flow(double val, const char *unit, Flow *flow) {
int i;
- i = index(unit, mass_flow_rate_units, n_mass_flow_rate_units, sizeof(mass_flow_rate_units[0]), cmp_flow_unit);
+ i = lsearch(unit, mass_flow_rate_units, n_mass_flow_rate_units, sizeof(*mass_flow_rate_units), cmp_flow_unit);
if (i >= 0) {
flow->u.mfr = mass_flow_rate_makers[i](val);
flow->t = MASS_FLOW;
@@ -234,7 +234,7 @@ static int
parse_volume_flow(double val, const char *unit, Flow *flow) {
int i;
- i = index(unit, volume_flow_rate_units, n_volume_flow_rate_units, sizeof(volume_flow_rate_units[0]), cmp_flow_unit);
+ i = lsearch(unit, volume_flow_rate_units, n_volume_flow_rate_units, sizeof(volume_flow_rate_units[0]), cmp_flow_unit);
if (i >= 0) {
flow->u.vfr = volume_flow_rate_makers[i](val);
flow->t = VOLUME_FLOW;
@@ -244,12 +244,12 @@ parse_volume_flow(double val, const char *unit, Flow *flow) {
return 1;
}
-/* index linearly searches base[0]...base[n-1] for an item that matches *key.
+/* lsearch linearly searches base[0]...base[n-1] for an item that matches *key.
* The function cmp must return zero if its first argument (the search key)
* equals its second (a table entry), non-zero if not equal.
* Returns the index of the first occurrence of key in base, or -1 if not present. */
static int
-index(const void *key, const void *base, size_t n, size_t size, int (*cmp)(const void *keyval, const void *datum)) {
+lsearch(const void *key, const void *base, size_t n, size_t size, int (*cmp)(const void *keyval, const void *datum)) {
size_t i;
for (i = 0; i < n; i++) {