develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #114248] perlclib differs from perlapi regarding Newx andrelated functions

Thread Previous | Thread Next
From:
Alexandre Jousset
Date:
July 23, 2012 18:04
Subject:
Re: [perl #114248] perlclib differs from perlapi regarding Newx andrelated functions
Message ID:
500DF492.4080904@gtmp.org
	Hi,

Le 24/07/2012 02:14, James E Keenan via RT a écrit :
> On Mon Jul 23 15:06:13 2012, BKB wrote:
>> The Perlclib documentation contains a discrepancy with the Perlapi
>> documentation for the functions Newx and related functions. Perlclib
>> gives these an initial argument of "id" but Perlapi does not mention
>> the "id" argument.
>
> The relevant code in pod/perlclib.pod dates to 2005-07-12.
>
> #####
>      102     t* p = malloc(n)                Newx(id, p, n, t)
>      103     t* p = calloc(n, s)             Newxz(id, p, n, t)
> #####
>
> pod/perlapi.pod is not source code POD.  Rather, it's built up from
> documentation in source code files.  The source code file in question
> appears to be handy.h.  But, surprisingly, the relevant code in handy.h
> dates to 2005-07-11!
>
> #####
>     1052 =for apidoc Am|void|Newx|void* ptr|int nitems|type
>     1053 The XSUB-writer's interface to the C C<malloc> function.
>     1054
>     1055 In 5.9.3, Newx() and friends replace the older New() API, and drops
>     1056 the first parameter, I<x>, a debug aid which allowed callers to
> identify
>     1057 themselves.  This aid has been superseded by a new build option,
>     1058 PERL_MEM_LOG (see L<perlhacktips/PERL_MEM_LOG>).  The older API
> is still
>     1059 there for use in XS modules supporting older perls.
> ...
>     1232 #define Newx(v,n,t)     (v = (MEM_WRAP_CHECK_(n,t)
> (t*)MEM_LOG_ALLOC(n,t,safemalloc((MEM_SIZE)((n)*sizeof(t))))))
>     1233 #define Newxc(v,n,t,c)  (v = (MEM_WRAP_CHECK_(n,t)
> (c*)MEM_LOG_ALLOC(n,t,safemalloc((MEM_SIZE)((n)*sizeof(t))))))
>     1234 #define Newxz(v,n,t)    (v = (MEM_WRAP_CHECK_(n,t)
> (t*)MEM_LOG_ALLOC(n,t,safecalloc((n),sizeof(t)))))
>     1235
>     1236 #ifndef PERL_CORE
>     1237 /* pre 5.9.x compatibility */
>     1238 #define New(x,v,n,t)    Newx(v,n,t)
>     1239 #define Newc(x,v,n,t,c) Newxc(v,n,t,c)
>     1240 #define Newz(x,v,n,t)   Newxz(v,n,t)
>     1241 #endif
> #####
>
> We'll need some suggestions from people more knowledgeable about these
> functions.

	I'm not especially "more knowledgeable about these functions" but just reading the comment and the code in handy.h against the perlclib.pod makes me think the person who added the 'x' in the perlclib.pod lines (the day after) forgot to remove the first argument "id". As it is stated it is the purpose of the new functions, to remove the first argument.

	Maybe this obvious thought is wrong, but I would be interested to know why ;-)

	My 2p.
-- 
--      \^/                                            --
--    -/ O \---------------------------------------    --
--   | |/ \|      Alexandre (Midnite) Jousset      |   --
--    -|___|---------------------------------------    --

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About