OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / mallopt.3
index f8848ab..2a11c8f 100644 (file)
@@ -1,6 +1,7 @@
 '\" t
 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -20,8 +21,9 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
-.TH MALLOPT 3  2012-03-22 "Linux" "Linux Programmer's Manual"
+.TH MALLOPT 3  2012-04-30 "Linux" "Linux Programmer's Manual"
 .SH NAME
 mallopt \- set memory allocation parameters
 .SH SYNOPSIS
@@ -176,7 +178,7 @@ The initial value of the threshold is 128*1024,
 but when blocks larger than the current threshold and less than or equal to
 .BR DEFAULT_MMAP_THRESHOLD_MAX
 are freed,
-the threshold is adjusted upwards to the size of the freed block.
+the threshold is adjusted upward to the size of the freed block.
 When dynamic mmap thresholding is in effect,
 the threshold for trimming the heap is also dynamically adjusted
 to be twice the dynamic mmap threshold.
@@ -217,7 +219,7 @@ in the least significant byte of
 .IR value ,
 and when allocated memory is released using
 .BR free (3),
-the freed bytes are ANded with the value in the least significant byte of
+the freed bytes are set to the least significant byte of
 .IR value .
 This can be useful for detecting errors where programs
 incorrectly rely on allocated memory being initialized to zero,
@@ -300,7 +302,7 @@ and wasting unused memory at the top of the heap
 .\" These macros aren't enabled in production releases until 2.15?
 .\" (see glibc malloc/Makefile)
 .\"
-.SS Environment Variables
+.SS Environment variables
 A number of environment variables can be defined
 to modify some of the same parameters as are controlled by
 .BR mallopt ().
@@ -309,7 +311,7 @@ of the program need not be changed.
 To be effective, these variables must be defined before the
 first call to a memory-allocation function.
 (If the same parameters are adjusted via
-.BR mallopt ()
+.BR mallopt (),
 then the
 .BR mallopt ()
 settings take precedence.)
@@ -478,6 +480,7 @@ under glibc, with the default value for
 .nf
 
 $ \fB./a.out\fP
+main(): returned from first free() call
 *** glibc detected *** ./a.out: double free or corruption (top): 0x09d30008 ***
 ======= Backtrace: =========
 /lib/libc.so.6(+0x6c501)[0x523501]
@@ -497,7 +500,7 @@ Aborted (core dumped)
 .in
 .PP
 The following runs show the results when employing other values for
-.BR M_CHECK_ACTION:
+.BR M_CHECK_ACTION :
 .PP
 .in +4n
 .nf
@@ -539,17 +542,12 @@ main(int argc, char *argv[])
     char *p;
 
     if (argc > 1) {
-        if (argc != 2) {
-            fprintf(stderr, "%s <M_CHECK_ACTION\-value>\\n", argv[0]);
+        if (mallopt(M_CHECK_ACTION, atoi(argv[1])) != 1) {
+            fprintf(stderr, "mallopt() failed");
             exit(EXIT_FAILURE);
         }
     }
 
-    if (mallopt(M_CHECK_ACTION, atoi(argv[1])) != 1) {
-        fprintf(stderr, "mallopt() failed");
-        exit(EXIT_FAILURE);
-    }
-
     p = malloc(1000);
     if (p == NULL) {
         fprintf(stderr, "malloc() failed");
@@ -568,10 +566,23 @@ main(int argc, char *argv[])
 .SH SEE ALSO
 .ad l
 .nh
-.BR mmap (2)
+.BR mmap (2),
 .BR sbrk (2),
 .BR mallinfo (3),
 .BR malloc (3),
 .BR malloc_hook (3),
+.BR malloc_info (3),
+.BR malloc_stats (3),
+.BR malloc_trim (3),
+.BR mcheck (3),
 .BR mtrace (3),
 .BR posix_memalign (3)
+.SH COLOPHON
+This page is part of release 3.68 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.