From 6871825565d0ba24436dbd5b92cc09e02f93af6a Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 26 Oct 2026 16:59:39 +0100 Subject: First run of making variable names more readable --- ot_vector.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ot_vector.c') diff --git a/ot_vector.c b/ot_vector.c index 7f18246..924d468 100644 --- a/ot_vector.c +++ b/ot_vector.c @@ -19,7 +19,7 @@ static int vector_compare_peer4(const void *peer1, const void *peer2) { return m no exact match is found. In that case it sets exactmatch 0 and gives calling functions the chance to insert data */ -void *binary_search(const void *const key, const void *base, const size_t member_count, const size_t member_size, size_t compare_size, int *exactmatch) { +void *vector_binary_search(const void *const key, const void *base, const size_t member_count, const size_t member_size, size_t compare_size, int *exactmatch) { size_t interval = member_count; while (interval) { @@ -50,13 +50,13 @@ static uint8_t vector_hash_peer(ot_peer const *peer, size_t compare_size, size_t /* This is the generic insert operation for our vector type. It tries to locate the object at "key" with size "member_size" by comparing its first "compare_size" bytes with - those of objects in vector. Our special "binary_search" function does that and either returns the match or a + those of objects in vector. Our special "vector_binary_search" function does that and either returns the match or a pointer to where the object is to be inserted. vector_find_or_insert makes space for the object and copies it, if it wasn't found in vector. Caller needs to check the passed "exactmatch" variable to see, whether an insert took place. If resizing the vector failed, NULL is returned, else the pointer to the object in vector. */ void *vector_find_or_insert(ot_vector *vector, void *key, size_t member_size, size_t compare_size, int *exactmatch) { - uint8_t *match = binary_search(key, vector->data, vector->size, member_size, compare_size, exactmatch); + uint8_t *match = vector_binary_search(key, vector->data, vector->size, member_size, compare_size, exactmatch); if (*exactmatch) return match; @@ -89,7 +89,7 @@ ot_peer *vector_find_or_insert_peer(ot_vector *vector, ot_peer const *peer, size /* If space is zero but size is set, we're dealing with a list of vector->size buckets */ if (vector->space < vector->size) vector = ((ot_vector *)vector->data) + vector_hash_peer(peer, compare_size, vector->size); - match = binary_search(peer, vector->data, vector->size, peer_size, compare_size, exactmatch); + match = vector_binary_search(peer, vector->data, vector->size, peer_size, compare_size, exactmatch); if (*exactmatch) return match; @@ -137,7 +137,7 @@ int vector_remove_peer(ot_vector *vector, ot_peer const *peer, size_t peer_size) vector = ((ot_vector *)vector->data) + vector_hash_peer(peer, compare_size, vector->size); end = ((ot_peer *)vector->data) + peer_size * vector->size; - match = (ot_peer *)binary_search(peer, vector->data, vector->size, peer_size, compare_size, &exactmatch); + match = (ot_peer *)vector_binary_search(peer, vector->data, vector->size, peer_size, compare_size, &exactmatch); if (!exactmatch) return 0; -- cgit v1.3