X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/9965345dfe11415fe4409828505acf6c7fe193b9..3afb2f14ba09da7b54ce62a6f12d9703a7776666:/pod/perlclib.pod diff --git a/pod/perlclib.pod b/pod/perlclib.pod index e89a67a..1fe4699 100644 --- a/pod/perlclib.pod +++ b/pod/perlclib.pod @@ -99,12 +99,12 @@ 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) - memcpy/*(struct foo *) StructCopy(src, dst, t) + memcpy(dst, src, sizeof(t)) StructCopy(src, dst, t) memset(dst, 0, n * sizeof(t)) Zero(dst, n, t) memzero(dst, 0) Zero(dst, n, char) free(p) Safefree(p) @@ -132,15 +132,18 @@ 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 any code attempting to use the data without forethought will break sooner rather than later. Poisoning can be done using the Poison() -macro, which has similar arguments as Zero(): +macros, which have similar arguments as Zero(): - Poison(dst, n, t) + PoisonWith(dst, n, t, b) scribble memory with byte b + PoisonNew(dst, n, t) equal to PoisonWith(dst, n, t, 0xAB) + PoisonFree(dst, n, t) equal to PoisonWith(dst, n, t, 0xEF) + Poison(dst, n, t) equal to PoisonFree(dst, n, t) =head2 Character Class Tests @@ -173,9 +176,9 @@ table, C is a C, and C is a Unicode codepoint. atof(s) Atof(s) atol(s) Atol(s) - strtod(s, *p) Nothing. Just don't use it. - strtol(s, *p, n) Strtol(s, *p, n) - strtoul(s, *p, n) Strtoul(s, *p, n) + strtod(s, &p) Nothing. Just don't use it. + strtol(s, &p, n) Strtol(s, &p, n) + strtoul(s, &p, n) Strtoul(s, &p, n) Notice also the C, C, and C functions in F for converting strings representing numbers in the respective @@ -205,5 +208,5 @@ For C/C, use C. =head1 SEE ALSO -C, C, C +L, L, L