aboutsummaryrefslogtreecommitdiffstats
path: root/regcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index f24c0c46e3..b8a0723d01 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5202,6 +5202,20 @@ onig_free(regex_t* reg)
}
}
+size_t
+onig_memsize(regex_t *reg)
+{
+ size_t size = sizeof(regex_t);
+ if (IS_NOT_NULL(reg->p)) size += reg->alloc;
+ if (IS_NOT_NULL(reg->exact)) size += reg->exact_end - reg->exact;
+ if (IS_NOT_NULL(reg->int_map)) size += sizeof(int) * ONIG_CHAR_TABLE_SIZE;
+ if (IS_NOT_NULL(reg->int_map_backward)) size += sizeof(int) * ONIG_CHAR_TABLE_SIZE;
+ if (IS_NOT_NULL(reg->repeat_range)) size += reg->repeat_range_alloc * sizeof(OnigRepeatRange);
+ if (IS_NOT_NULL(reg->chain)) size += onig_memsize(reg->chain);
+
+ return size;
+}
+
#define REGEX_TRANSFER(to,from) do {\
(to)->state = ONIG_STATE_MODIFY;\
onig_free_body(to);\