summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-15 04:15:54 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-15 04:15:54 (GMT)
commit84dcc38273665cba3f3756a454697edf11ab168a (patch)
treedbfd3e77fe3ffa4f26efea788f02279d66af9d60 /regcomp.c
parent15f26afdf0cf3f188a20456512c829290187b68d (diff)
* regcomp.c (onig_region_memsize): implemented for memsize_of().
* ext/objspace/objspace.c (memsize_of): use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 98ecbe8..d81334a 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5244,6 +5244,7 @@ size_t
onig_memsize(const regex_t *reg)
{
size_t size = sizeof(regex_t);
+ if (!reg) return 0;
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;
@@ -5254,6 +5255,15 @@ onig_memsize(const regex_t *reg)
return size;
}
+size_t
+onig_region_memsize(const OnigRegion *regs)
+{
+ size_t size = sizeof(*regs);
+ if (!regs) return 0;
+ size += regs->allocated * (sizeof(*regs->beg) + sizeof(*regs->end));
+ return size;
+}
+
#define REGEX_TRANSFER(to,from) do {\
(to)->state = ONIG_STATE_MODIFY;\
onig_free_body(to);\