summaryrefslogtreecommitdiff
path: root/src/stdlib/bsearch_s.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-30 14:57:46 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-30 14:57:46 -0500
commitcc6e7378d3f5473137e0c46d39173e6f60dcefda (patch)
tree4cd2883ad16fd594b7777b6f3821d5b9177af5c4 /src/stdlib/bsearch_s.c
parent000a7c045c98c30aac86db93f8c9c978e5ca8c59 (diff)
update standards and safety checks
Diffstat (limited to 'src/stdlib/bsearch_s.c')
-rw-r--r--src/stdlib/bsearch_s.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/stdlib/bsearch_s.c b/src/stdlib/bsearch_s.c
index dfa1a7ed..706aa399 100644
--- a/src/stdlib/bsearch_s.c
+++ b/src/stdlib/bsearch_s.c
@@ -1,18 +1,20 @@
-#if 0
-
#include <stddef.h>
+#include "_stdlib.h"
/** binary search **/
void *bsearch_s(const void * key, const void * base, rsize_t nmemb, rsize_t size, int (*compar)(const void *x, const void *y, void * context), void *context)
{
+ SIGNAL_SAFE(0);
+
/* TODO: testing */
+ (void)size;
void *ret = NULL;
size_t i = nmemb / 2;
unsigned int trip = 1;
while (ret == NULL) {
- int comp = compar(key, base+i);
+ int comp = compar(key, base+i, context);
if (comp == 0) {
return (void*)base+i;
} else if (comp > 0) {
@@ -47,6 +49,3 @@ element.
/*
CEXT1(201112)
*/
-
-
-#endif