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

[perl #114248] perlclib differs from perlapi regarding Newx and related functions

Thread Next
From:
James E Keenan via RT
Date:
July 23, 2012 17:14
Subject:
[perl #114248] perlclib differs from perlapi regarding Newx and related functions
Message ID:
rt-3.6.HEAD-11172-1343088877-658.114248-15-0@perl.org
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.

Thank you very much.
jimk

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114248

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