summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ptrarray.c7
-rw-r--r--src/ptrarray.h1
2 files changed, 7 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;
+}
diff --git a/src/ptrarray.h b/src/ptrarray.h
index 2c6136a..ed67351 100644
--- a/src/ptrarray.h
+++ b/src/ptrarray.h
@@ -36,4 +36,5 @@ void ptr_array_insert(ptrarray_t *pa, void *data, long index);
void ptr_array_remove(ptrarray_t *pa, long index);
void ptr_array_set(ptrarray_t *pa, void *data, long index);
void* ptr_array_index(ptrarray_t *pa, long index);
+long ptr_array_size(ptrarray_t *pa);
#endif