summaryrefslogtreecommitdiff
path: root/darray.h
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2026-01-14 17:09:26 -0500
committerPeter Zhu <peter@peterzhu.ca>2026-01-15 17:57:27 -0500
commitf7ae32ed3b5b93247f9f62a58e3dd129098d0b27 (patch)
tree7c54a86e2eed05e2b04343e146541f6156337f01 /darray.h
parent6e480e6714f0e63bc065f4d931f76e087131c743 (diff)
Pin ID symbols
Symbols with a corresponding ID should be pinned because they can be used by things that don't support compaction.
Diffstat (limited to 'darray.h')
-rw-r--r--darray.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/darray.h b/darray.h
index dc9d282be2..10fd5e4ccc 100644
--- a/darray.h
+++ b/darray.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
+#include "ruby/ruby.h"
// Type for a dynamic array. Use to declare a dynamic array.
// It is a pointer so it fits in st_table nicely. Designed
@@ -147,6 +148,9 @@ rb_darray_size(const void *ary)
return meta ? meta->size : 0;
}
+/* Estimate of the amount of memory used by this darray.
+ * Useful for TypedData objects. */
+#define rb_darray_memsize(ary) (sizeof(*(ary)) + (rb_darray_size(ary) * sizeof((ary)->data[0])))
static inline void
rb_darray_pop(void *ary, size_t count)