X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/154e47c821a043f6b3b7346ca0c21e3282802f49..22d36020eee5daeca31211c83f903b5ad55305f7:/pod/perlguts.pod diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 70b9187..b9f6ba7 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1602,73 +1602,6 @@ functions: For a detailed description of calling conventions from C to Perl, consult L. -=head2 Memory Allocation - -=head3 Allocation - -All memory meant to be used with the Perl API functions should be manipulated -using the macros described in this section. The macros provide the necessary -transparency between differences in the actual malloc implementation that is -used within perl. - -It is suggested that you enable the version of malloc that is distributed -with Perl. It keeps pools of various sizes of unallocated memory in -order to satisfy allocation requests more quickly. However, on some -platforms, it may cause spurious malloc or free errors. - -The following three macros are used to initially allocate memory : - - Newx(pointer, number, type); - Newxc(pointer, number, type, cast); - Newxz(pointer, number, type); - -The first argument C should be the name of a variable that will -point to the newly allocated memory. - -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, -should be used if the C argument is different from the C -argument. - -Unlike the C and C macros, the C macro calls C -to zero out all the newly allocated memory. - -=head3 Reallocation - - Renew(pointer, number, type); - Renewc(pointer, number, type, cast); - Safefree(pointer) - -These three macros are used to change a memory buffer size or to free a -piece of memory no longer needed. The arguments to C and C -match those of C and C with the exception of not needing the -"magic cookie" argument. - -=head3 Moving - - Move(source, dest, number, type); - Copy(source, dest, number, type); - Zero(dest, number, type); - -These three macros are used to move, copy, or zero out previously allocated -memory. The C and C arguments point to the source and -destination starting points. Perl will move, copy, or zero out C -instances of the size of the C data structure (using the C -function). - -=head2 PerlIO - -The most recent development releases of Perl have been experimenting with -removing Perl's dependency on the "normal" standard I/O suite and allowing -other stdio implementations to be used. This involves creating a new -abstraction layer that then calls whichever implementation of stdio Perl -was compiled with. All XSUBs should now use the functions in the PerlIO -abstraction layer and not make any assumptions about what kind of stdio -is being used. - -For a complete description of the PerlIO abstraction, consult L. - =head2 Putting a C value on Perl stack A lot of opcodes (this is an elementary operation in the internal perl @@ -1764,6 +1697,73 @@ if it is, new scratchpad is created and pushed into the array. The Is on this scratchpad are Cs, but they are already marked with correct flags. +=head1 Memory Allocation + +=head2 Allocation + +All memory meant to be used with the Perl API functions should be manipulated +using the macros described in this section. The macros provide the necessary +transparency between differences in the actual malloc implementation that is +used within perl. + +It is suggested that you enable the version of malloc that is distributed +with Perl. It keeps pools of various sizes of unallocated memory in +order to satisfy allocation requests more quickly. However, on some +platforms, it may cause spurious malloc or free errors. + +The following three macros are used to initially allocate memory : + + Newx(pointer, number, type); + Newxc(pointer, number, type, cast); + Newxz(pointer, number, type); + +The first argument C should be the name of a variable that will +point to the newly allocated memory. + +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, +should be used if the C argument is different from the C +argument. + +Unlike the C and C macros, the C macro calls C +to zero out all the newly allocated memory. + +=head2 Reallocation + + Renew(pointer, number, type); + Renewc(pointer, number, type, cast); + Safefree(pointer) + +These three macros are used to change a memory buffer size or to free a +piece of memory no longer needed. The arguments to C and C +match those of C and C with the exception of not needing the +"magic cookie" argument. + +=head2 Moving + + Move(source, dest, number, type); + Copy(source, dest, number, type); + Zero(dest, number, type); + +These three macros are used to move, copy, or zero out previously allocated +memory. The C and C arguments point to the source and +destination starting points. Perl will move, copy, or zero out C +instances of the size of the C data structure (using the C +function). + +=head1 PerlIO + +The most recent development releases of Perl have been experimenting with +removing Perl's dependency on the "normal" standard I/O suite and allowing +other stdio implementations to be used. This involves creating a new +abstraction layer that then calls whichever implementation of stdio Perl +was compiled with. All XSUBs should now use the functions in the PerlIO +abstraction layer and not make any assumptions about what kind of stdio +is being used. + +For a complete description of the PerlIO abstraction, consult L. + =head1 Compiled code =head2 Code tree