Skip to content

Commit 9a2915c

Browse files
committed
Merge branch 'fixes-for-upstream' of https://github.com/doctaweeks/json-c into doctaweeks-fixes-for-upstream
2 parents b2c5969 + 92e9a50 commit 9a2915c

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

arraylist.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ array_list_new(array_list_free_fn *free_fn)
4444
extern void
4545
array_list_free(struct array_list *arr)
4646
{
47-
int i;
47+
size_t i;
4848
for(i = 0; i < arr->length; i++)
4949
if(arr->array[i]) arr->free_fn(arr->array[i]);
5050
free(arr->array);
5151
free(arr);
5252
}
5353

5454
void*
55-
array_list_get_idx(struct array_list *arr, int i)
55+
array_list_get_idx(struct array_list *arr, size_t i)
5656
{
5757
if(i >= arr->length) return NULL;
5858
return arr->array[i];
5959
}
6060

61-
static int array_list_expand_internal(struct array_list *arr, int max)
61+
static int array_list_expand_internal(struct array_list *arr, size_t max)
6262
{
6363
void *t;
64-
int new_size;
64+
size_t new_size;
6565

6666
if(max < arr->size) return 0;
6767
/* Avoid undefined behaviour on int32 overflow */
@@ -82,7 +82,7 @@ static int array_list_expand_internal(struct array_list *arr, int max)
8282
}
8383

8484
int
85-
array_list_put_idx(struct array_list *arr, int idx, void *data)
85+
array_list_put_idx(struct array_list *arr, size_t idx, void *data)
8686
{
8787
if( idx < 0 || idx > INT_MAX - 1 ) return -1;
8888
if(array_list_expand_internal(arr, idx+1)) return -1;
@@ -111,7 +111,7 @@ void* array_list_bsearch(const void **key, struct array_list *arr,
111111
sort_fn);
112112
}
113113

114-
int
114+
size_t
115115
array_list_length(struct array_list *arr)
116116
{
117117
return arr->length;

arraylist.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ typedef void (array_list_free_fn) (void *data);
2323
struct array_list
2424
{
2525
void **array;
26-
int length;
27-
int size;
26+
size_t length;
27+
size_t size;
2828
array_list_free_fn *free_fn;
2929
};
3030

@@ -35,15 +35,15 @@ extern void
3535
array_list_free(struct array_list *al);
3636

3737
extern void*
38-
array_list_get_idx(struct array_list *al, int i);
38+
array_list_get_idx(struct array_list *al, size_t i);
3939

4040
extern int
41-
array_list_put_idx(struct array_list *al, int i, void *data);
41+
array_list_put_idx(struct array_list *al, size_t i, void *data);
4242

4343
extern int
4444
array_list_add(struct array_list *al, void *data);
4545

46-
extern int
46+
extern size_t
4747
array_list_length(struct array_list *al);
4848

4949
extern void

json_object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ static int json_object_array_to_json_string(struct json_object* jso,
879879
int flags)
880880
{
881881
int had_children = 0;
882-
int ii;
882+
size_t ii;
883883
sprintbuf(pb, "[");
884884
if (flags & JSON_C_TO_STRING_PRETTY)
885885
sprintbuf(pb, "\n");
@@ -975,7 +975,7 @@ struct json_object* json_object_array_bsearch(
975975
return *result;
976976
}
977977

978-
int json_object_array_length(const struct json_object *jso)
978+
size_t json_object_array_length(const struct json_object *jso)
979979
{
980980
return array_list_length(jso->o.c_array);
981981
}
@@ -985,14 +985,14 @@ int json_object_array_add(struct json_object *jso,struct json_object *val)
985985
return array_list_add(jso->o.c_array, val);
986986
}
987987

988-
int json_object_array_put_idx(struct json_object *jso, int idx,
988+
int json_object_array_put_idx(struct json_object *jso, size_t idx,
989989
struct json_object *val)
990990
{
991991
return array_list_put_idx(jso->o.c_array, idx, val);
992992
}
993993

994994
struct json_object* json_object_array_get_idx(const struct json_object *jso,
995-
int idx)
995+
size_t idx)
996996
{
997997
return (struct json_object*)array_list_get_idx(jso->o.c_array, idx);
998998
}

json_object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ extern struct array_list* json_object_get_array(const struct json_object *obj);
457457
* @param obj the json_object instance
458458
* @returns an int
459459
*/
460-
extern int json_object_array_length(const struct json_object *obj);
460+
extern size_t json_object_array_length(const struct json_object *obj);
461461

462462
/** Sorts the elements of jso of type json_type_array
463463
*
@@ -515,7 +515,7 @@ extern int json_object_array_add(struct json_object *obj,
515515
* @param idx the index to insert the element at
516516
* @param val the json_object to be added
517517
*/
518-
extern int json_object_array_put_idx(struct json_object *obj, int idx,
518+
extern int json_object_array_put_idx(struct json_object *obj, size_t idx,
519519
struct json_object *val);
520520

521521
/** Get the element at specificed index of the array (a json_object of type json_type_array)
@@ -524,7 +524,7 @@ extern int json_object_array_put_idx(struct json_object *obj, int idx,
524524
* @returns the json_object at the specified index (or NULL)
525525
*/
526526
extern struct json_object* json_object_array_get_idx(const struct json_object *obj,
527-
int idx);
527+
size_t idx);
528528

529529
/** Delete an elements from a specified index in an array (a json_object of type json_type_array)
530530
*

0 commit comments

Comments
 (0)