summaryrefslogtreecommitdiff
path: root/darray.h
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-09-09 15:35:47 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:40 -0400
commit11599e5e1ebed485089a994753a9c3c79416c037 (patch)
treef6e868aeaa01cbf2c53f07150cf7e75c337c10b6 /darray.h
parentf380856923f066e02fb1233c720a6abdc645d11f (diff)
downloadruby-11599e5e1ebed485089a994753a9c3c79416c037.tar.gz
Add rb_darray_clear() for Kevin. Fix some warnings.
Diffstat (limited to 'darray.h')
-rw-r--r--darray.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/darray.h b/darray.h
index b613d08489..ed6085fbcd 100644
--- a/darray.h
+++ b/darray.h
@@ -84,6 +84,11 @@
//
#define rb_darray_make(ptr_to_ary, size) rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), sizeof((*(ptr_to_ary))->data[0]))
+// Set the size of the array to zero without freeing the backing memory.
+// Allows reusing the same array.
+//
+#define rb_darray_clear(ary) (ary->meta.size = 0)
+
typedef struct rb_darray_meta {
int32_t size;
int32_t capa;