sort-util: make bsearch_safe() actually typesafe, by returning the right type
This commit is contained in:
committed by
Luca Boccassi
parent
2b5b25f123
commit
423e2400af
@@ -18,7 +18,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
|
||||
({ \
|
||||
const typeof((b)[0]) *_k = k; \
|
||||
int (*_func_)(const typeof((b)[0])*, const typeof((b)[0])*, typeof(userdata)) = func; \
|
||||
xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \
|
||||
(typeof((b)[0])*) xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ static inline void* bsearch_safe(const void *key, const void *base,
|
||||
({ \
|
||||
const typeof((b)[0]) *_k = k; \
|
||||
int (*_func_)(const typeof((b)[0])*, const typeof((b)[0])*) = func; \
|
||||
bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \
|
||||
(typeof((b)[0])*) bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user