Grokbase
x

Torsten Foertsch (torsten.foe...@gmx.net)

Profile | Posts (68)

User Information

Display Name:Torsten Foertsch
Partial Email Address:torsten.foe...@gmx.net
Posts:
68 total
25 in mod_perl
43 in Perl 5 Porters

5 Most Recent

All Posts
1) Torsten Foertsch Perl IO documentation
| +1 vote
Hi, where can I read more about perl IO? Are there API docs that explain what can be used and what...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hi,

where can I read more about perl IO? Are there API docs that explain what can
be used and what should better be avoided in external modules?

The reason for the question is this, why are there 2 FPs in an IO? There is an
IFP and an OFP, why? Can I open a file by IoIFP(io)=PerlIO_fdopen(1, "w")? Is
this sufficient?

Thanks,
Torsten
2) Torsten Foertsch Re: XS question
| +1 vote
Actually SvFAKE_on(sv) leads to Assertion he->shared_he_he.hent_hek == hek failed: file "hv.c",...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu 02 Jul 2009, Torsten Foertsch wrote:
> > I think tt may be safer to also set SVf_FAKE, so that your sv will
> > appear as a shared SV. As such, it's pretty unlikely perl will ever
> > try to free the content buffer.
>
> I thought so but I haven't found any documentation about that flag.
> Is there any? BTW, is SVf_FAKE available in 5.8.8?

Actually SvFAKE_on(sv) leads to

Assertion he->shared_he_he.hent_hek == hek failed: file "hv.c", line
2257.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
3) Torsten Foertsch Re: XS question
| +1 vote
I thought so but I haven't found any documentation about that flag. Is there any? BTW, is SVf_FAKE...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu 02 Jul 2009, Vincent Pit wrote:
> > To answer myself, I think this does the trick:
> >
> >       sv=newSV(0);
> >       SvUPGRADE(sv, SVt_PV);
> >       SvPOK_only(sv);
> >       SvPV_set(sv, pointer);
> >       SvLEN_set(sv, 0);
> >       SvCUR_set(sv, length);
> >       SvREADONLY_on(sv);
> >
> > It depends on the fact that Safefree is not called if SvLEN(sv)==0.
> > Can I rely on that in the future?
> >
> > Torsten
> >  
>
> I think tt may be safer to also set SVf_FAKE, so that your sv will
> appear as a shared SV. As such, it's pretty unlikely perl will ever
> try to free the content buffer.

I thought so but I haven't found any documentation about that flag. Is
there any? BTW, is SVf_FAKE available in 5.8.8?

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
4) Torsten Foertsch Re: XS question
| +1 vote
To answer myself, I think this does the trick: sv=newSV(0); SvUPGRADE(sv, SVt_PV); SvPOK_only(sv);...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu 02 Jul 2009, Torsten Foertsch wrote:
> I have a bunch of C-strings with or without a trailing \0. I want to
> make them available in Perl as read-only variables. When the perl SV
> is destroyed the string must not be freed obviously.
>
> Do I need to make those variables magic? Or is there a simpler way?

To answer myself, I think this does the trick:

      sv=newSV(0);
      SvUPGRADE(sv, SVt_PV);
      SvPOK_only(sv);
      SvPV_set(sv, pointer);
      SvLEN_set(sv, 0);
      SvCUR_set(sv, length);
      SvREADONLY_on(sv);

It depends on the fact that Safefree is not called if SvLEN(sv)==0. Can
I rely on that in the future?

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
5) Torsten Foertsch XS question
| +1 vote
Hi, perhaps this is not the right list but I know the knowledge is here. So, please be lenient. I...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hi,

perhaps this is not the right list but I know the knowledge is here. So,
please be lenient.

I have a bunch of C-strings with or without a trailing \0. I want to
make them available in Perl as read-only variables. When the perl SV is
destroyed the string must not be freed obviously.

Do I need to make those variables magic? Or is there a simpler way?

If I need magic, do I need to implement all of the 8 MGVTBL members?
What if some of them are NULL?

I think I need only an svt_free function that does:

SvPVX(var) = NULL;
SvCUR(var) = 0;

Is this correct?

I have read somewhere that perl strings do not need the trailing \0
byte. But for some reasons it is normally allocated. Why? Is it
necessary? What can happen if there is no trailing \0?

Thanks,
Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

spacer
Profile | Posts (68)
Home > People > Torsten Foertsch