#!/usr/bin/perl -- use strict; use warnings; use Inline C => Config => BUILD_NOISY => 1, CLEAN_AFTER_BUILD => 0; use Inline 'C' => <<'CODE', NAME => 'xiaoyafeng'; int ddd(SV* x){ printf("SV* x is %p \n", x); SvUTF8_off(x); SvGROW(x,8); SvCUR_set(x, 8); printf("SvPV(x) is p(%p) \n", SvPV_nolen(x)); printf("SvPV(x) is s(%s) \n", SvPV_nolen(x)); char*buff = SvPV_nolen(x); Copy( "dddddddd", buff , 8, char); printf("SvPV(x) is p(%p) \n", SvPV_nolen(x)); printf("SvPV(x) is s(%s) \n", SvPV_nolen(x)); printf("string buff is p(%p) \n", buff); printf("string buff is s(%s) \n", buff); SvSETMAGIC(x); return 0; } CODE use Devel::Peek qw/ Dump /; my $x = ""; Dump $x; ddd($x); Dump $x; exit( 0 ); __END__ SV = PV(0x3f7a8c) at 0x99bca4 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0xb2ac54 ""\0 CUR = 0 LEN = 12 SV* x is 0099BCA4 SvPV(x) is p(00B2AC54) SvPV(x) is s() SvPV(x) is p(00B2AC54) SvPV(x) is s(ddddddddng) string buff is p(00B2AC54) string buff is s(ddddddddng) SV = PV(0x3f7a8c) at 0x99bca4 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0xb2ac54 "dddddddd" CUR = 8 LEN = 12

In reply to Re^2: What difference between malloc and Newx, how attach a C string to SV directly? by Anonymous Monk
in thread What difference between malloc and Newx, how attach a C string to SV directly? by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.