From: Eric Haszlakiewicz Date: Wed, 4 Mar 2015 03:10:10 +0000 (+0000) Subject: Slight style tweaks to the bsearch changest. X-Git-Tag: json-c-0.13-20171207~199 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=484ca368f07054cde67cea5a5fa43ce3b049e667;p=thirdparty%2Fjson-c.git Slight style tweaks to the bsearch changest. --- diff --git a/arraylist.c b/arraylist.c index 5ccbdd22..8efe006e 100644 --- a/arraylist.c +++ b/arraylist.c @@ -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); } -void* array_list_bsearch( const void **key, struct array_list *arr, - int (*sort_fn)(const void *, const void *) ) +void* array_list_bsearch(const void **key, struct array_list *arr, + int (*sort_fn)(const void *, const void *)) { - return bsearch( key, arr->array, arr->length, sizeof(arr->array[0]), - sort_fn ); + return bsearch(key, arr->array, arr->length, sizeof(arr->array[0]), + sort_fn); } int diff --git a/arraylist.h b/arraylist.h index 50fb3207..caecdfa5 100644 --- a/arraylist.h +++ b/arraylist.h @@ -49,9 +49,9 @@ array_list_length(struct array_list *al); extern 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, - int (*sort_fn)(const void *, const void *) ); + int (*sort_fn)(const void *, const void *)); #ifdef __cplusplus diff --git a/json_object.c b/json_object.c index c858a9ef..9b89bb76 100644 --- a/json_object.c +++ b/json_object.c @@ -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( const struct json_object *key, const struct json_object *jso, - int (*sort_fn)(const void *, const void *) ) + int (*sort_fn)(const void *, const void *)) { struct json_object **result; - result = (struct json_object **) array_list_bsearch( - (const void **) &key, jso->o.c_array, sort_fn ); + result = (struct json_object **)array_list_bsearch( + (const void **)&key, jso->o.c_array, sort_fn); - if ( result == NULL ) { + if (!result) return NULL; - } else { - return *result; - } + return *result; } int json_object_array_length(struct json_object *jso) diff --git a/json_object.h b/json_object.h index e1858aac..2bdfd5f9 100644 --- a/json_object.h +++ b/json_object.h @@ -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( const struct json_object *key, 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 *