Browse Source

#723

pull/724/head
correy 4 years ago
parent
commit
ac76669cbc
5 changed files with 11 additions and 9 deletions
  1. +2
    -2
      arraylist.c
  2. +3
    -2
      arraylist.h
  3. +3
    -2
      json_object.c
  4. +2
    -2
      json_object.h
  5. +1
    -1
      strerror_override.c

+ 2
- 2
arraylist.c View File

@@ -166,13 +166,13 @@ int array_list_add(struct array_list *arr, void *data)
return 0;
}

void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *))
void array_list_sort(struct array_list *arr, int(__cdecl *compar)(const void *, const void *))
{
qsort(arr->array, arr->length, sizeof(arr->array[0]), compar);
}

void *array_list_bsearch(const void **key, struct array_list *arr,
int (*compar)(const void *, const void *))
int(__cdecl *compar)(const void *, const void *))
{
return bsearch(key, arr->array, arr->length, sizeof(arr->array[0]), compar);
}


+ 3
- 2
arraylist.h View File

@@ -68,10 +68,11 @@ extern int array_list_add(struct array_list *al, void *data);

extern size_t 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_sort(struct array_list *arr,
int(__cdecl *compar)(const void *, const void *));

extern void *array_list_bsearch(const void **key, struct array_list *arr,
int (*compar)(const void *, const void *));
int(__cdecl *compar)(const void *, const void *));

extern int array_list_del_idx(struct array_list *arr, size_t idx, size_t count);



+ 3
- 2
json_object.c View File

@@ -1463,7 +1463,8 @@ struct array_list *json_object_get_array(const struct json_object *jso)
}
}

void json_object_array_sort(struct json_object *jso, int (*sort_fn)(const void *, const void *))
void json_object_array_sort(struct json_object *jso,
int(__cdecl *sort_fn)(const void *, const void *))
{
assert(json_object_get_type(jso) == json_type_array);
array_list_sort(JC_ARRAY(jso)->c_array, sort_fn);
@@ -1471,7 +1472,7 @@ 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(__cdecl *sort_fn)(const void *, const void *))
{
struct json_object **result;



+ 2
- 2
json_object.h View File

@@ -556,7 +556,7 @@ JSON_EXPORT size_t json_object_array_length(const struct json_object *obj);
* @param sort_fn a sorting function
*/
JSON_EXPORT void json_object_array_sort(struct json_object *jso,
int (*sort_fn)(const void *, const void *));
int(__cdecl *sort_fn)(const void *, const void *));

/** Binary search a sorted array for a specified key object.
*
@@ -574,7 +574,7 @@ JSON_EXPORT void json_object_array_sort(struct json_object *jso,
*/
JSON_EXPORT 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(__cdecl *sort_fn)(const void *, const void *));

/** Add an element to the end of a json_object of type json_type_array
*


+ 1
- 1
strerror_override.c View File

@@ -60,7 +60,7 @@ static struct

// Enabled during tests
static int _json_c_strerror_enable = 0;
extern char *getenv(const char *name); // Avoid including stdlib.h
extern char * __cdecl getenv(const char *name); // Avoid including stdlib.h

#define PREFIX "ERRNO="
static char errno_buf[128] = PREFIX;


Loading…
Cancel
Save