diff options
author | Daniel M. Weeks <dan@danweeks.net> | 2014-08-22 10:56:59 -0400 |
---|---|---|
committer | Daniel M. Weeks <dan@danweeks.net> | 2015-11-24 14:00:31 -0500 |
commit | 45c56b80c4b8a121e6eecbbe5cfeae74060b0468 (patch) | |
tree | 5aaef7eda45628a480bb1cd40d63cd9830cd97b7 /arraylist.c | |
parent | c97bbd37972bd6e0ec9163a15db30b0159261be1 (diff) | |
download | json-c-45c56b80c4b8a121e6eecbbe5cfeae74060b0468.tar.gz |
Use size_t for array list length and size
Diffstat (limited to 'arraylist.c')
-rw-r--r-- | arraylist.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/arraylist.c b/arraylist.c index 8efe006..54fd2bb 100644 --- a/arraylist.c +++ b/arraylist.c @@ -42,7 +42,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); @@ -50,16 +50,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; new_size = arr->size << 1; @@ -73,7 +73,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(array_list_expand_internal(arr, idx+1)) return -1; if(arr->array[idx]) arr->free_fn(arr->array[idx]); @@ -101,7 +101,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; |