summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFlorian Ragwitz <rafl@debian.org>2010-11-25 02:40:00 +0100
committerFlorian Ragwitz <rafl@debian.org>2010-11-30 12:37:29 +0100
commit39de7f53b474076d5a8e28b5b41fddefd29e45d7 (patch)
treeb27c20c09b496e75b9eee2c3a778196aead62ba0 /mg.c
parentb83794c7d64c56b8d918c51e93d1136d33fa202b (diff)
downloadperl-39de7f53b474076d5a8e28b5b41fddefd29e45d7.tar.gz
Add mg_findext
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/mg.c b/mg.c
index e734d8028b..39f07f53d0 100644
--- a/mg.c
+++ b/mg.c
@@ -416,6 +416,26 @@ Perl_mg_clear(pTHX_ SV *sv)
return 0;
}
+MAGIC*
+S_mg_findext_flags(pTHX_ const SV *sv, int type, const MGVTBL *vtbl, U32 flags)
+{
+ PERL_UNUSED_CONTEXT;
+
+ assert(flags <= 1);
+
+ if (sv) {
+ MAGIC *mg;
+
+ for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
+ if (mg->mg_type == type && (!flags || mg->mg_virtual == vtbl)) {
+ return mg;
+ }
+ }
+ }
+
+ return NULL;
+}
+
/*
=for apidoc mg_find
@@ -427,15 +447,22 @@ Finds the magic pointer for type matching the SV. See C<sv_magic>.
MAGIC*
Perl_mg_find(pTHX_ const SV *sv, int type)
{
- PERL_UNUSED_CONTEXT;
- if (sv) {
- MAGIC *mg;
- for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- if (mg->mg_type == type)
- return mg;
- }
- }
- return NULL;
+ return S_mg_findext_flags(aTHX_ sv, type, NULL, 0);
+}
+
+/*
+=for apidoc mg_findext
+
+Finds the magic pointer of C<type> with the given C<vtbl> for the C<SV>. See
+C<sv_magicext>.
+
+=cut
+*/
+
+MAGIC*
+Perl_mg_findext(pTHX_ const SV *sv, int type, const MGVTBL *vtbl)
+{
+ return S_mg_findext_flags(aTHX_ sv, type, vtbl, 1);
}
/*