Slight style tweaks to the bsearch changest.
This commit is contained in:
@@ -94,11 +94,11 @@ array_list_sort(struct array_list *arr, int(*sort_fn)(const void *, const void *
|
|||||||
qsort(arr->array, arr->length, sizeof(arr->array[0]), sort_fn);
|
qsort(arr->array, arr->length, sizeof(arr->array[0]), sort_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* array_list_bsearch( const void **key, struct array_list *arr,
|
void* array_list_bsearch(const void **key, struct array_list *arr,
|
||||||
int (*sort_fn)(const void *, const void *) )
|
int (*sort_fn)(const void *, const void *))
|
||||||
{
|
{
|
||||||
return bsearch( key, arr->array, arr->length, sizeof(arr->array[0]),
|
return bsearch(key, arr->array, arr->length, sizeof(arr->array[0]),
|
||||||
sort_fn );
|
sort_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ array_list_length(struct array_list *al);
|
|||||||
extern void
|
extern void
|
||||||
array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *));
|
array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *));
|
||||||
|
|
||||||
extern void* array_list_bsearch( const void **key,
|
extern void* array_list_bsearch(const void **key,
|
||||||
struct array_list *arr,
|
struct array_list *arr,
|
||||||
int (*sort_fn)(const void *, const void *) );
|
int (*sort_fn)(const void *, const void *));
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -892,18 +892,16 @@ void json_object_array_sort(struct json_object *jso, int(*sort_fn)(const void *,
|
|||||||
struct json_object* json_object_array_bsearch(
|
struct json_object* json_object_array_bsearch(
|
||||||
const struct json_object *key,
|
const struct json_object *key,
|
||||||
const struct json_object *jso,
|
const struct json_object *jso,
|
||||||
int (*sort_fn)(const void *, const void *) )
|
int (*sort_fn)(const void *, const void *))
|
||||||
{
|
{
|
||||||
struct json_object **result;
|
struct json_object **result;
|
||||||
|
|
||||||
result = (struct json_object **) array_list_bsearch(
|
result = (struct json_object **)array_list_bsearch(
|
||||||
(const void **) &key, jso->o.c_array, sort_fn );
|
(const void **)&key, jso->o.c_array, sort_fn);
|
||||||
|
|
||||||
if ( result == NULL ) {
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
return *result;
|
||||||
return *result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int json_object_array_length(struct json_object *jso)
|
int json_object_array_length(struct json_object *jso)
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ extern void json_object_array_sort(struct json_object *jso, int(*sort_fn)(const
|
|||||||
extern struct json_object* json_object_array_bsearch(
|
extern struct json_object* json_object_array_bsearch(
|
||||||
const struct json_object *key,
|
const struct json_object *key,
|
||||||
const struct json_object *jso,
|
const struct json_object *jso,
|
||||||
int (*sort_fn)(const void *, const void *) );
|
int (*sort_fn)(const void *, const void *));
|
||||||
|
|
||||||
/** Add an element to the end of a json_object of type json_type_array
|
/** Add an element to the end of a json_object of type json_type_array
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user