From: Steve Hay Date: Tue, 12 Jul 2005 08:17:47 +0000 (+0000) Subject: Change New*() to Newx*() in various comments and documentation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f653bb54868b8547466924d4ce483acb8987efb;p=p5sagit%2Fp5-mst-13.2.git Change New*() to Newx*() in various comments and documentation p4raw-id: //depot/perl@25116 --- diff --git a/handy.h b/handy.h index 72b967e..539bf76 100644 --- a/handy.h +++ b/handy.h @@ -639,7 +639,7 @@ hopefully catches attempts to access uninitialized memory. #ifdef PERL_MEM_LOG /* - * If PERL_MEM_LOG is defined, all New()s, Renew()s, and Safefree()s + * If PERL_MEM_LOG is defined, all Newx()s, Renew()s, and Safefree()s * go through functions, which are handy for debugging breakpoints, but * which more importantly get the immediate calling environment (file and * line number) passed in. This can then be used for logging the calls, diff --git a/perl.c b/perl.c index e2872c6..e6bb9dd 100644 --- a/perl.c +++ b/perl.c @@ -165,7 +165,7 @@ perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS, struct IPerlProc* ipP) { PerlInterpreter *my_perl; - /* New() needs interpreter, so call malloc() instead */ + /* Newx() needs interpreter, so call malloc() instead */ my_perl = (PerlInterpreter*)(*ipM->pMalloc)(ipM, sizeof(PerlInterpreter)); S_init_tls_and_interp(my_perl); Zero(my_perl, 1, PerlInterpreter); @@ -198,7 +198,7 @@ perl_alloc(void) { PerlInterpreter *my_perl; - /* New() needs interpreter, so call malloc() instead */ + /* Newx() needs interpreter, so call malloc() instead */ my_perl = (PerlInterpreter*)PerlMem_malloc(sizeof(PerlInterpreter)); S_init_tls_and_interp(my_perl); diff --git a/pod/perlclib.pod b/pod/perlclib.pod index e89a67a..837a36d 100644 --- a/pod/perlclib.pod +++ b/pod/perlclib.pod @@ -99,8 +99,8 @@ There is no equivalent to C; one should use C instead: Instead Of: Use: - t* p = malloc(n) New(id, p, n, t) - t* p = calloc(n, s) Newz(id, p, n, t) + t* p = malloc(n) Newx(id, p, n, t) + t* p = calloc(n, s) Newxz(id, p, n, t) p = realloc(p, n) Renew(p, n, t) memcpy(dst, src, n) Copy(src, dst, n, t) memmove(dst, src, n) Move(src, dst, n, t) @@ -132,7 +132,7 @@ instead of raw C strings: Note also the existence of C and C, combining concatenation with formatting. -Sometimes instead of zeroing the allocated heap by using Newz() you +Sometimes instead of zeroing the allocated heap by using Newxz() you should consider "poisoning" the data. This means writing a bit pattern into it that should be illegal as pointers (and floating point numbers), and also hopefully surprising enough as integers, so that diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 34c6412..82910c0 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1490,25 +1490,20 @@ platforms, it may cause spurious malloc or free errors. The following three macros are used to initially allocate memory : - New(x, pointer, number, type); - Newc(x, pointer, number, type, cast); - Newz(x, pointer, number, type); + Newx(pointer, number, type); + Newxc(pointer, number, type, cast); + Newxz(pointer, number, type); -The first argument C was a "magic cookie" that was used to keep track -of who called the macro, to help when debugging memory problems. However, -the current code makes no use of this feature (most Perl developers now -use run-time memory checkers), so this argument can be any number. - -The second argument C should be the name of a variable that will +The first argument C should be the name of a variable that will point to the newly allocated memory. -The third and fourth arguments C and C specify how many of +The second and third arguments C and C specify how many of the specified type of data structure should be allocated. The argument -C is passed to C. The final argument to C, C, +C is passed to C. The final argument to C, C, should be used if the C argument is different from the C argument. -Unlike the C and C macros, the C macro calls C +Unlike the C and C macros, the C macro calls C to zero out all the newly allocated memory. =head3 Reallocation diff --git a/pod/perlhack.pod b/pod/perlhack.pod index 31dab0e..f797851 100644 --- a/pod/perlhack.pod +++ b/pod/perlhack.pod @@ -2470,7 +2470,7 @@ your favourite debugger to discover where those pesky SVs were allocated. =head2 PERL_MEM_LOG -If compiled with C<-DPERL_MEM_LOG>, all New() and Renew() allocations +If compiled with C<-DPERL_MEM_LOG>, all Newx() and Renew() allocations and Safefree() in the Perl core go through logging functions, which is handy for breakpoint setting. If also compiled with C<-DPERL_MEM_LOG_STDERR>, the allocations and frees are logged to STDERR in these logging functions, diff --git a/sv.c b/sv.c index 0687df1..3d17b1d 100644 --- a/sv.c +++ b/sv.c @@ -4577,7 +4577,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) } SvFAKE_off(sv); SvREADONLY_off(sv); - /* This SV doesn't own the buffer, so need to New() a new one: */ + /* This SV doesn't own the buffer, so need to Newx() a new one: */ SvPV_set(sv, (char*)0); SvLEN_set(sv, 0); if (flags & SV_COW_DROP_PV) {