mirror of
https://github.com/json-c/json-c.git
synced 2026-03-21 05:59:07 +08:00
Merge branch 'fixes-for-upstream' of https://github.com/doctaweeks/json-c into doctaweeks-fixes-for-upstream
This commit is contained in:
12
arraylist.c
12
arraylist.c
@@ -44,7 +44,7 @@ array_list_new(array_list_free_fn *free_fn)
|
||||
extern void
|
||||
array_list_free(struct array_list *arr)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
for(i = 0; i < arr->length; i++)
|
||||
if(arr->array[i]) arr->free_fn(arr->array[i]);
|
||||
free(arr->array);
|
||||
@@ -52,16 +52,16 @@ array_list_free(struct array_list *arr)
|
||||
}
|
||||
|
||||
void*
|
||||
array_list_get_idx(struct array_list *arr, int i)
|
||||
array_list_get_idx(struct array_list *arr, size_t i)
|
||||
{
|
||||
if(i >= arr->length) return NULL;
|
||||
return arr->array[i];
|
||||
}
|
||||
|
||||
static int array_list_expand_internal(struct array_list *arr, int max)
|
||||
static int array_list_expand_internal(struct array_list *arr, size_t max)
|
||||
{
|
||||
void *t;
|
||||
int new_size;
|
||||
size_t new_size;
|
||||
|
||||
if(max < arr->size) return 0;
|
||||
/* Avoid undefined behaviour on int32 overflow */
|
||||
@@ -82,7 +82,7 @@ static int array_list_expand_internal(struct array_list *arr, int max)
|
||||
}
|
||||
|
||||
int
|
||||
array_list_put_idx(struct array_list *arr, int idx, void *data)
|
||||
array_list_put_idx(struct array_list *arr, size_t idx, void *data)
|
||||
{
|
||||
if( idx < 0 || idx > INT_MAX - 1 ) return -1;
|
||||
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,
|
||||
sort_fn);
|
||||
}
|
||||
|
||||
int
|
||||
size_t
|
||||
array_list_length(struct array_list *arr)
|
||||
{
|
||||
return arr->length;
|
||||
|
||||
Reference in New Issue
Block a user