Stas Bekman <[EMAIL PROTECTED]> writes:
[...]
> As most of the time internal mp magic doesn't use the mg_obj slot, I'm
> trying to just to hang the pool object there. that will solve the problem of
> double magic
+1- I used that fact in certain places within apreq2 to avoid it,
so I think it can work.
> (I still can't figure how using perl public API one finds more than
> one magic of the same type)
You can't use mg_find, but you could walk the SvMAGIC linked-list
manually (it's a public struct). I think people used mg_ptr as
a tag string to differentiate different ext-magics, but I have not
actually seen it done in practice.
> and will save some memory too.
>
> #define mpxs_add_pool_magic(obj, pool_obj) \
> if (mpxs_pool_is_custom(SvRV(pool_obj))) { \
> MAGIC *mg = mg_find(SvRV(obj), PERL_MAGIC_ext); \
> if (mg) { \
> if (mg->mg_obj == Nullsv) { \
> mg->mg_obj = SvREFCNT_inc(pool_obj); \
> mg->mg_flags |= MGf_REFCOUNTED; \
> } \
> else { \
> Perl_croak(aTHX_ "Fixme: don't know how to " \
> "handle non-Nullsv magic"); \
> } \
> } \
> else { \
> mpxs_add_pool_magic_doit(obj, pool_obj); \
> } \
> }
Looks good!
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]