diff options
author | XD | 2019-12-09 01:07:32 +0100 |
---|---|---|
committer | Nikias Bassen | 2019-12-09 01:07:32 +0100 |
commit | 4289c5eb8d18fa64ea92b1f8d013011b58f8edbb (patch) | |
tree | c665c1e12a6f5e0a5f68e3f19d508f6b0b4eadb6 /src/ptrarray.c | |
parent | 344328d18c2332798c7637eabf3e8797ce9333dc (diff) | |
download | libplist-4289c5eb8d18fa64ea92b1f8d013011b58f8edbb.tar.gz libplist-4289c5eb8d18fa64ea92b1f8d013011b58f8edbb.tar.bz2 |
ptrarray: Add function returning the size (number of elements) of the array
Diffstat (limited to 'src/ptrarray.c')
-rw-r--r-- | src/ptrarray.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ptrarray.c b/src/ptrarray.c index bcffb77..c499773 100644 --- a/src/ptrarray.c +++ b/src/ptrarray.c @@ -42,7 +42,7 @@ void ptr_array_free(ptrarray_t *pa) void ptr_array_insert(ptrarray_t *pa, void *data, long array_index) { - if (!pa || !pa->pdata || !data) return; + if (!pa || !pa->pdata) return; long remaining = pa->capacity-pa->len; if (remaining == 0) { pa->pdata = realloc(pa->pdata, sizeof(void*) * (pa->capacity + pa->capacity_step)); @@ -89,3 +89,8 @@ void* ptr_array_index(ptrarray_t *pa, long array_index) } return pa->pdata[array_index]; } + +long ptr_array_size(ptrarray_t *pa) +{ + return pa->len; +} |