Skip to content

Commit 86444e5

Browse files
committed
Sync darray.h
1 parent 58605dd commit 86444e5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

darray.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <stdint.h>
55
#include <stddef.h>
66
#include <stdlib.h>
7+
#include "ruby/ruby.h"
78

89
// Type for a dynamic array. Use to declare a dynamic array.
910
// It is a pointer so it fits in st_table nicely. Designed
@@ -147,6 +148,9 @@ rb_darray_size(const void *ary)
147148
return meta ? meta->size : 0;
148149
}
149150

151+
/* Estimate of the amount of memory used by this darray.
152+
* Useful for TypedData objects. */
153+
#define rb_darray_memsize(ary) (sizeof(*(ary)) + (rb_darray_size(ary) * sizeof((ary)->data[0])))
150154

151155
static inline void
152156
rb_darray_pop(void *ary, size_t count)

0 commit comments

Comments
 (0)