Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libc/bsearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
*
*************************************************/
void *bsearch(
void *keyp, void *ptr, size_t num, size_t width,
const void *keyp, const void *ptr, size_t num, size_t width,
int (*comp)(const void *, const void *)
) {
char *key = keyp;
char *base = ptr;
const char *key = keyp;
const char *base = ptr;
unsigned int mid;
unsigned int low;
unsigned int high;
Expand Down Expand Up @@ -66,7 +66,7 @@ void *bsearch(
continue; /* than the key. */
}

d = (*comp)(key,addr = base + mid * width);
d = (*comp)(key,addr = (char*)(base + mid * width));
if (d == 0) /* we found it */
return(addr);
if (d < 0) /* key is less than mid, */
Expand Down
2 changes: 1 addition & 1 deletion src/libc/include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void srand(unsigned int seed);

int rand(void);

void *bsearch(void *key, void *base, size_t nmemb, size_t size,
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *))
__attribute__((nonnull(1, 2, 5)));

Expand Down
Loading