perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] pools that go out of scope aren't a problem anymore?
Date Sat, 27 Nov 2004 18:01:34 GMT
Stas Bekman wrote:
[...]
> So trying to go the way Joe has chosen for apreq, I've replaced the 
> plain apr_table_make autogenerated wrapper with explicit:
> 
> static MP_INLINE SV *mpxs_APR__Table_make(pTHX_ SV *p_sv, int nelts)
> {
>     apr_pool_t *p = mp_xs_sv2_APR__Pool(p_sv);
>     apr_table_t *t = apr_table_make(p, nelts);
>     SV *t_sv = mp_xs_APR__Table_2obj(t);
>     sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1);
>     return t_sv;
> }

That code wasn't correct, the good one is:

Index: xs/maps/apr_functions.map
===================================================================
--- xs/maps/apr_functions.map	(revision 106595)
+++ xs/maps/apr_functions.map	(working copy)
@@ -244,7 +244,8 @@
  MODULE=APR::Table
   apr_table_clear
   apr_table_copy    | | t, p
- apr_table_make
+~apr_table_make
+ mpxs_APR__Table_make
   apr_table_overlap
   apr_table_overlay | | base, overlay, p
   apr_table_compress
Index: xs/APR/Table/APR__Table.h
===================================================================
--- xs/APR/Table/APR__Table.h	(revision 106595)
+++ xs/APR/Table/APR__Table.h	(working copy)
@@ -17,6 +17,17 @@
  #define mpxs_APR__Table_DELETE  apr_table_unset
  #define mpxs_APR__Table_CLEAR   apr_table_clear

+
+static MP_INLINE SV *mpxs_APR__Table_make(pTHX_ SV *p_sv, int nelts)
+{
+    apr_pool_t *p = mp_xs_sv2_APR__Pool(p_sv);
+    apr_table_t *t = apr_table_make(p, nelts);
+    SV *t_sv = modperl_hash_tie(aTHX_ "APR::Table", Nullsv, t);
+    sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1);
+    return t_sv;
+}
+
+
  typedef struct {
      SV *cv;
      apr_hash_t *filter;

We need to figure out how to automate this.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message