Skip to content

Commit 1a3f733

Browse files
committed
fixed bsearch prototype
1 parent 834875c commit 1a3f733

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libc/bsearch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
*
2727
*************************************************/
2828
void *bsearch(
29-
void *keyp, void *ptr, size_t num, size_t width,
29+
const void *keyp, const void *ptr, size_t num, size_t width,
3030
int (*comp)(const void *, const void *)
3131
) {
32-
char *key = keyp;
33-
char *base = ptr;
32+
const char *key = keyp;
33+
const char *base = ptr;
3434
unsigned int mid;
3535
unsigned int low;
3636
unsigned int high;
@@ -66,7 +66,7 @@ void *bsearch(
6666
continue; /* than the key. */
6767
}
6868

69-
d = (*comp)(key,addr = base + mid * width);
69+
d = (*comp)(key,addr = (char*)(base + mid * width));
7070
if (d == 0) /* we found it */
7171
return(addr);
7272
if (d < 0) /* key is less than mid, */

src/libc/include/stdlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void srand(unsigned int seed);
7878

7979
int rand(void);
8080

81-
void *bsearch(void *key, void *base, size_t nmemb, size_t size,
81+
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
8282
int (*compar)(const void *, const void *))
8383
__attribute__((nonnull(1, 2, 5)));
8484

0 commit comments

Comments
 (0)