Home | History | Annotate | Download | only in mjsunit
      1 // Copyright 2008 the V8 project authors. All rights reserved.
      2 // Redistribution and use in source and binary forms, with or without
      3 // modification, are permitted provided that the following conditions are
      4 // met:
      5 //
      6 //     * Redistributions of source code must retain the above copyright
      7 //       notice, this list of conditions and the following disclaimer.
      8 //     * Redistributions in binary form must reproduce the above
      9 //       copyright notice, this list of conditions and the following
     10 //       disclaimer in the documentation and/or other materials provided
     11 //       with the distribution.
     12 //     * Neither the name of Google Inc. nor the names of its
     13 //       contributors may be used to endorse or promote products derived
     14 //       from this software without specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 // Texts are from the Unibrow test suite.
     29 
     30 // Note that this file is in UTF-8.  smjs and testkjs do not read their
     31 // source files as UTF-8, so they will fail on this test.  If you want
     32 // to run the test on them you can do so after filtering it with the
     33 // following piece of perl-based line noise:
     34 
     35 // perl -CIO -ne '$_ =~ s/([^\n -~])/"\\u" . sprintf("%04x", ord($1))/ge; print $_;' < unicode-test.js > unicode-test-ascii.js
     36 
     37 // The result is predictably illegible even for those fluent in Hindi.
     38 
     39 var chinese =
     40 "\n" +
     41 "[]\n" +
     42 " , \n" +
     43 "\n" +
     44 "\n" +
     45 "\n" +
     46 "\n" +
     47 "()\n" +
     48 "\n" +
     49 "\n" +
     50 " 	\n" +
     51 " 	\n" +
     52 "\n" +
     53 "\n" +
     54 " 	\n" +
     55 "\n" +
     56 "\n" +
     57 " 	 	 	\n" +
     58 "\n" +
     59 " 	\n" +
     60 " 	\n" +
     61 " 	\n" +
     62 " 	 	\n" +
     63 " 	\n" +
     64 "\n" +
     65 "\n" +
     66 "\n" +
     67 " 	\n" +
     68 " 	\n" +
     69 "\n" +
     70 " 	\n" +
     71 " 	\n" +
     72 "\n" +
     73 "\n" +
     74 "\n" +
     75 "\n" +
     76 "\n" +
     77 "\n" +
     78 "() 	\n" +
     79 " 	 	\n" +
     80 " 	\n" +
     81 "\n" +
     82 "\n" +
     83 "\n" +
     84 "\n" +
     85 "\n" +
     86 " 	\n" +
     87 "\n" +
     88 "\n" +
     89 "\n" +
     90 "    * \n" +
     91 "    * \n" +
     92 "    * \n" +
     93 "    * \n" +
     94 "    * \n" +
     95 "\n" +
     96 "\n" +
     97 "\n" +
     98 "\n" +
     99 " -  -  - \n" +
    100 " -  -  - \n" +
    101 " -  -  - \n" +
    102 " -  -  - \n" +
    103 " -  -  - \n" +
    104 "\n" +
    105 " -  - \n" +
    106 " -  -  - \n" +
    107 " -  -  - \n" +
    108 "\n" +
    109 " -  - \n" +
    110 " - \n" +
    111 " -  - \n" +
    112 " -  - \n" +
    113 "\n" +
    114 " - \n" +
    115 " -  -  - \n" +
    116 " - \n" +
    117 " - \n" +
    118 "\n" +
    119 " -  -  - \n" +
    120 " - \n" +
    121 "\n" +
    122 " -  -  - \n" +
    123 "\n" +
    124 "360040003600160040007000700010000200\n" +
    125 "\n" +
    126 "3000\n" +
    127 "\n" +
    128 "199019503019491980202\n" +
    129 "\n" +
    130 "[]\n" +
    131 "\n" +
    132 "    * 1 \n" +
    133 "    * 2 \n" +
    134 "    * 3 \n" +
    135 "          o 3.1 \n" +
    136 "          o 3.2 \n" +
    137 "    * 4 \n" +
    138 "    * 5 \n" +
    139 "    * 6 \n" +
    140 "    * 7 \n" +
    141 "    * 8 \n" +
    142 "          o 8.1 \n" +
    143 "    * 9 20\n" +
    144 "    * 10 \n" +
    145 "    * 11 \n" +
    146 "    * 12 \n" +
    147 "    * 13 \n" +
    148 "    * 14 \n" +
    149 "    * 15 \n" +
    150 "\n" +
    151 "[] \n" +
    152 "\n" +
    153 "\n" +
    154 "\n" +
    155 "450022425\n" +
    156 "\n" +
    157 "\n" +
    158 "5040201025001300\n" +
    159 "\n" +
    160 "50003000\n" +
    161 "\n" +
    162 "[] \n" +
    163 "\n" +
    164 "    \n" +
    165 "\n" +
    166 "\n" +
    167 "\n" +
    168 "\n" +
    169 "\n" +
    170 "\n" +
    171 "\n" +
    172 "\n" +
    173 "()400\n" +
    174 "\n" +
    175 "[] \n" +
    176 "\n" +
    177 "[] \n" +
    178 "\n" +
    179 "    \n" +
    180 "\n" +
    181 "\n" +
    182 "\n" +
    183 "\n" +
    184 "2116--161046\n" +
    185 "\n" +
    186 "1046[1]841\n" +
    187 "\n" +
    188 "[] \n" +
    189 "\n" +
    190 "     ()\n" +
    191 "\n" +
    192 "\n" +
    193 "\n" +
    194 "\n" +
    195 "770()546403356221\n" +
    196 "\n" +
    197 "\n" +
    198 "\n" +
    199 "\n" +
    200 "\n" +
    201 "[] \n" +
    202 "\n" +
    203 "    \n" +
    204 "\n" +
    205 "\n" +
    206 "\n" +
    207 "\n" +
    208 "221[]\n" +
    209 "\n" +
    210 "210206 202(\n" +
    211 "\n" +
    212 "925\n" +
    213 "\n" +
    214 "[] \n" +
    215 "\n" +
    216 "    \n" +
    217 "\n" +
    218 "\n" +
    219 "\n" +
    220 "\n" +
    221 "196220\n" +
    222 "\n" +
    223 "265280290304409, \n" +
    224 "\n" +
    225 "\n" +
    226 "\n" +
    227 "[] \n" +
    228 "\n" +
    229 "    \n" +
    230 "\n" +
    231 "\n" +
    232 "\n" +
    233 "\n" +
    234 "58158937\n" +
    235 "\n" +
    236 "6186261335(Manicheism)755\n" +
    237 "\n" +
    238 "875907\n" +
    239 "\n" +
    240 "[] \n" +
    241 "\n" +
    242 "    \n" +
    243 "\n" +
    244 "\n" +
    245 "\n" +
    246 "\n" +
    247 "960()(),,112511251127()\n" +
    248 "\n" +
    249 "()1234(, )127112798, .[]\n" +
    250 "\n" +
    251 "400500\n" +
    252 "\n" +
    253 "\n" +
    254 "\n" +
    255 "[] \n" +
    256 "\n" +
    257 "\n" +
    258 "\n" +
    259 "    \n" +
    260 "\n" +
    261 "13681405142116271644\n" +
    262 "\n" +
    263 "16441689191820\n" +
    264 "\n" +
    265 "191787181518381839623718406\n" +
    266 "\n" +
    267 "[] \n" +
    268 "\n" +
    269 "\n" +
    270 "\n" +
    271 "18418184282921001844\n" +
    272 "\n" +
    273 "185118641860\n" +
    274 "\n" +
    275 "191858601860186080040186444\n" +
    276 "\n" +
    277 "186018771881189421898611921103\n" +
    278 "\n" +
    279 "189919014.5399.8\n" +
    280 "\n" +
    281 "[] 20\n" +
    282 "\n" +
    283 "    \n" +
    284 "\n" +
    285 "19011912191683\n" +
    286 "\n" +
    287 "1921192419231925167192665192781811934\n" +
    288 "\n" +
    289 "\n" +
    290 "\n" +
    291 "19319181936121219377722194519461951194661949\n" +
    292 "\n" +
    293 "19561958195919611966197699 1978199219972002 \n" +
    294 "\n" +
    295 "19861987199620002005\n" +
    296 "\n" +
    297 "[] \n" +
    298 "\n" +
    299 "    * \n" +
    300 "    * \n" +
    301 "    * \n" +
    302 "    * \n" +
    303 "    * \n" +
    304 "\n" +
    305 "	\n" +
    306 "\n" +
    307 "    * \n" +
    308 "    * \n" +
    309 "    * \n" +
    310 "    * \n" +
    311 "    * \n" +
    312 "\n" +
    313 "	\n" +
    314 "\n" +
    315 "    * \n" +
    316 "    * \n" +
    317 "    * \n" +
    318 "    * \n" +
    319 "    * \n" +
    320 "\n" +
    321 "	\n" +
    322 "\n" +
    323 "    * \n" +
    324 "    * \n" +
    325 "    * \n" +
    326 "    * \n" +
    327 "    * \n" +
    328 "    * \n" +
    329 "\n" +
    330 "[] \n" +
    331 "\n" +
    332 "    * \n" +
    333 "    * \n" +
    334 "    * \n" +
    335 "    * \n" +
    336 "    * \n" +
    337 "    * \n" +
    338 "    * \n" +
    339 "    * \n" +
    340 "    * \n" +
    341 "    * \n" +
    342 "    * \n" +
    343 "    * \n" +
    344 "    * \n" +
    345 "\n" +
    346 "[] \n" +
    347 "\n" +
    348 "   1.  \n" +
    349 "\n" +
    350 "[] \n" +
    351 "\n" +
    352 "   1. 1993ISBN 7208001367\n" +
    353 "   2. 1995ISBN 7208003300\n" +
    354 "   3. 2000ISBN 9620418913\n" +
    355 "   4. 1962 11001241\n" +
    356 "   5. ()2001 ISBN 9622019870\n" +
    357 "   6. Korotayev A., Malkov A., Khaltourina D. Introduction to Social Macrodynamics: Secular Cycles and Millennial Trends. Moscow: URSS, 2006. ISBN 5-484-00559-0 [1] (Chapter 2: Historical Population Dynamics in China).\n" +
    358 "\n" +
    359 "[] \n" +
    360 "\n" +
    361 "    *  \n" +
    362 "    *  \n" +
    363 "    *  \n" +
    364 "    *  \n" +
    365 "\n" +
    366 "[] \n" +
    367 "\n" +
    368 "\n" +
    369 "\n" +
    370 "    * \n" +
    371 "    * \n" +
    372 "    *  - \n";
    373 
    374 var cyrillic =
    375 " \n" +
    376 "[]\n" +
    377 "     \n" +
    378 " : , \n" +
    379 " \n" +
    380 " \n" +
    381 "    \n" +
    382 " \n" +
    383 " \n" +
    384 "  	\n" +
    385 " \n" +
    386 "  	\n" +
    387 "\n" +
    388 " \n" +
    389 "( ) -  \n" +
    390 "  	 \n" +
    391 ",  \n" +
    392 " \n" +
    393 "  	 	 	\n" +
    394 "\n" +
    395 "	 \n" +
    396 "   	 \n" +
    397 "   \n" +
    398 " \n" +
    399 " \n" +
    400 "\n" +
    401 "	\n" +
    402 "5   10 \n" +
    403 " \n" +
    404 "	\n" +
    405 "\n" +
    406 "\n" +
    407 "	\n" +
    408 " \n" +
    409 "	\n" +
    410 " \n" +
    411 " \n" +
    412 " \n" +
    413 " \n" +
    414 " \n" +
    415 "  \n" +
    416 "	  ()\n" +
    417 "\n" +
    418 "       .    ,       ,          3500 .    ,      ,                ,      ,    -  .            (I   . .)     (II   . .).\n" +
    419 "\n" +
    420 "[]\n" +
    421 "\n" +
    422 "    * 1  \n" +
    423 "    * 2  -\n" +
    424 "    * 3   (XIIII .  . .)\n" +
    425 "    * 4  \n" +
    426 "    * 5  \n" +
    427 "    * 6     -  (IVVI .)\n" +
    428 "    * 7   (581618)\n" +
    429 "    * 8  \n" +
    430 "    * 9  \n" +
    431 "    * 10     (12801368)\n" +
    432 "    * 11   (13681644)\n" +
    433 "    * 12  \n" +
    434 "          o 12.1   \n" +
    435 "          o 12.2    \n" +
    436 "          o 12.3  \n" +
    437 "          o 12.4 -  18941895 \n" +
    438 "          o 12.5  \n" +
    439 "          o 12.6     \n" +
    440 "          o 12.7   \n" +
    441 "          o 12.8   \n" +
    442 "    * 13 XX \n" +
    443 "          o 13.1  \n" +
    444 "          o 13.2 - \n" +
    445 "          o 13.3  \n" +
    446 "          o 13.4  \n" +
    447 "          o 13.5  1911     \n" +
    448 "          o 13.6   \n" +
    449 "          o 13.7  \n" +
    450 "          o 13.8  \n" +
    451 "          o 13.9      \n" +
    452 "          o 13.10    \n" +
    453 "          o 13.11  \n" +
    454 "          o 13.12  \n" +
    455 "    * 14 . \n" +
    456 "    * 15 \n" +
    457 "\n" +
    458 "[]  \n" +
    459 "\n" +
    460 "  (   )    ( 1, ,  2, ,  2,  1  .)   (. 4500-2500  ..)    ,      .      (  .)     ().         (  )     (, , ).\n" +
    461 "\n" +
    462 "[]  -\n" +
    463 "\n" +
    464 "          -,   XIV   . .     ,   .\n" +
    465 "\n" +
    466 "           XI   . .       ,        .               .                 ,   , ,    .           .\n" +
    467 "\n" +
    468 " XI   . .        ,         ,       .\n" +
    469 "\n" +
    470 "[]   (XIIII .  . .)\n" +
    471 "     .  , V-III .  ..\n" +
    472 "     .  , V-III .  ..\n" +
    473 "\n" +
    474 "   ,     ,             ,    ,            ( -  . )   ( - , ).             .        ,        .\n" +
    475 "\n" +
    476 "   ,         .             ,        (  ).\n" +
    477 "\n" +
    478 "         ,        ,  (  ),       .\n" +
    479 "\n" +
    480 "  (XIIII .  . .)        ,        770  . .              .            ,      .         .\n" +
    481 "\n" +
    482 "  ,   ,    :\n" +
    483 "\n" +
    484 "    *  (     VIIIV .  . .);\n" +
    485 "    *  (  , VIII .  . .).\n" +
    486 "\n" +
    487 "        ,   (-),      (-),   ,        ,    .    (  )     (-),      .\n" +
    488 "\n" +
    489 "            (VIV .  . .),  (V .  . .),  (IV .  . .), .\n" +
    490 "\n" +
    491 " VIII .  .. ( )     .   ,   ,  ,      .\n" +
    492 "\n" +
    493 "           ,    (      ), , ,   .            .      ,  221  . .               .\n" +
    494 "\n" +
    495 "   III   . .    .\n" +
    496 "\n" +
    497 "[]  \n" +
    498 "\n" +
    499 "  ,         ,                    36  ,    .\n" +
    500 "\n" +
    501 "       ()        .          .        ()     .          ,       .\n" +
    502 "   ,     6700 ,    III   . .        .\n" +
    503 "   ,     6700 ,    III   . .        .\n" +
    504 "\n" +
    505 " ,              ,  ,    ( )       ,          .\n" +
    506 "\n" +
    507 "        .\n" +
    508 "\n" +
    509 "[]  \n" +
    510 "\n" +
    511 "    ,    (206  . .220 . .)        (-),      ,          210 .  ..\n" +
    512 "\n" +
    513 "        ,             ,    . -            .\n" +
    514 "\n" +
    515 "        ,           - ,       .       ,           .\n" +
    516 "\n" +
    517 "  - (206195  ..)     ,     .\n" +
    518 "\n" +
    519 "  - (14087  . .)           ,                .          .\n" +
    520 "\n" +
    521 "      .      (   , -      ),          ,   ,    -,     .\n" +
    522 "\n" +
    523 "              (, ,   .).                         .       -         .\n" +
    524 "\n" +
    525 " I . . .       .\n" +
    526 "\n" +
    527 "   8  23 . . .    ,       .   ,     -    . -     .           .    ,  ,    .\n" +
    528 "\n" +
    529 "     ,    220 . . .\n" +
    530 "\n" +
    531 "[]     -  (IVVI .)\n" +
    532 "\n" +
    533 "     (,   ).             (265420).\n" +
    534 "\n" +
    535 "  IV        (), , ,   .      ,     ,   16   .         -,       .\n" +
    536 "\n" +
    537 "  ,   ,               , , ,     (, , , ,   .).\n" +
    538 "\n" +
    539 "  ,   ,         , ,  , ,    .    , -                            ,   .   VI        .\n" +
    540 "\n" +
    541 "               ( ),        ( )    V             .     VI ,   , -      .\n" +
    542 "\n" +
    543 "      ,       ,         ,   ,   ,    ,  ,     .   ,   ,              .   V          .       ,   ,      .      .\n" +
    544 "\n" +
    545 "                    2 . .                   .   ,    ,                .     .\n" +
    546 "\n" +
    547 "[]   (581618)\n" +
    548 "\n" +
    549 "            .  581                  (581618),         .   VII            (611 - 614)    ,              ,      ,        ,      .\n" +
    550 "\n" +
    551 "       .   ,       (618907),      .\n" +
    552 "\n" +
    553 "[]  \n" +
    554 "\n" +
    555 "            .     10 ,   \" \",   ,   ,     .         .\n" +
    556 "\n" +
    557 "  VII              -  - . ,      ,      .         .     .\n" +
    558 "\n" +
    559 " VIIIX .          , , .\n" +
    560 "\n" +
    561 "  ,     (),    ,  ,     .\n" +
    562 "\n" +
    563 " VIII             .           874901.\n" +
    564 "\n" +
    565 "    (907960)        ,     ,    .\n" +
    566 "\n" +
    567 "[]  \n" +
    568 "\n" +
    569 " 960   -    (9601279).                .\n" +
    570 "\n" +
    571 "   X         ,     -.  ,   916    1125,   .     ,      (     ).          ,            ,  , , .         ,         1004       .  1042   ,   1075       .\n" +
    572 "\n" +
    573 "     -   ,    ,   XXI .       .        ,       -  .  1047          .\n" +
    574 "\n" +
    575 "              .   ,     ,         , , , ,    .    ,  ,     ,   .            ,               ().\n" +
    576 " .       (XII ).\n" +
    577 " .       (XII ).\n" +
    578 "\n" +
    579 " XII            ,  (     1125   )  (  )  (11151234),     . .        ,           -    (11241211).\n" +
    580 "\n" +
    581 " 1127             .       ,  ,         (11271280).         .            .           .\n" +
    582 "\n" +
    583 " 1141   ,              .\n" +
    584 "\n" +
    585 "[]     (12801368)\n" +
    586 "\n" +
    587 "  XIII     .  XIII       ,    \"\".         ,     ,    ,     ,           ,   , ,   . .\n" +
    588 "\n" +
    589 "        ,           .  1206              ,     .\n" +
    590 "\n" +
    591 "     ,            .\n" +
    592 "\n" +
    593 "    ,   1210       1215  .\n" +
    594 "\n" +
    595 " 12191221        .  1223    ,  12261227    .  1231          1234     .\n" +
    596 "\n" +
    597 "        1250-,          .    ,  -     (12521253),  (1253).  1258             ,           (1259).  ,   ,  1260        (  ,   1264     ).          1276.  1280    ,     .\n" +
    598 "\n" +
    599 "         (12711368),      , ,       ,         .\n" +
    600 "\n" +
    601 " ,    ,   ,   .      .     .         (  ),    1334         .         .\n" +
    602 "\n" +
    603 "          ,        ().\n" +
    604 "\n" +
    605 "[]   (13681644)\n" +
    606 "\n" +
    607 "      XIV    .            ,   (13681644).\n" +
    608 "\n" +
    609 ",   ,       .       ,   (    ),      .\n" +
    610 "\n" +
    611 "     ,      ,    1405  1433      - ,      .      ,   ,    .\n" +
    612 "\n" +
    613 " XVI           .          , , .  1557         ().        .          ,  ,     .         .\n" +
    614 "\n" +
    615 "[]  \n" +
    616 "\n" +
    617 "  XVI         ,     ,          (15591626).  1609     ,      .  1618      .           (  ).\n" +
    618 "\n" +
    619 "           .   XVII     () .             .\n" +
    620 "\n" +
    621 " ,   ,      ,        .              .        .  1644      ,    ,  ,       .       . 6  1644   .    ,          .           .\n" +
    622 "\n" +
    623 "      ,            .         1683.\n" +
    624 "\n" +
    625 "       1644  1911 .           .    ,       ,   ,    ,      .\n" +
    626 "\n" +
    627 "   (  16621723),     ,     .       XVIIXVIII .   .   XIX       300 .       ,         .             .     ,           .\n" +
    628 "\n" +
    629 "[]   \n" +
    630 "\n" +
    631 "         .      .           XVII ,       ,      .   XVIII      ,       ().       ,    .\n" +
    632 "\n" +
    633 "      ,       ,      ,     .\n" +
    634 "\n" +
    635 "   .   XVIII      () .  1757    ,        1760            ( ).    -         XVIII     .      (17651769)   (17881789)       .\n" +
    636 "\n" +
    637 "      -,         .         .         , , ,      .\n" +
    638 "\n" +
    639 "                 .\n" +
    640 "\n" +
    641 "[]    \n" +
    642 "\n" +
    643 "     : - \n" +
    644 "\n" +
    645 "    -         ( .   16181619),    (   16541657,    16751678  .)     .               (16431646)    (16491653)             ,          .\n" +
    646 "\n" +
    647 "  XVII         - (,   .),    .  1656    (  ) ,           .\n" +
    648 "\n" +
    649 "          ( ),  1650-                     .    -      .            1686             .\n" +
    650 "\n" +
    651 "      .       -,     ,     .    -   ,     ,  ,          .\n" +
    652 "\n" +
    653 "   ,             .               .         .       .     ,    , ,             .            XIX .            (1858)   (1860) ;               . ; -          1890-.\n" +
    654 "\n" +
    655 "[]  \n" +
    656 "    1875\n" +
    657 "    1875\n" +
    658 "\n" +
    659 "  XVIII         .  , ,         ,    -   ,         .                      ,    .          ,         XIX .              .\n" +
    660 "\n" +
    661 "[] -  18941895 \n" +
    662 "\n" +
    663 " 1874    ,        .       ,        .   1894             .   ,      ,        ,       .\n" +
    664 "\n" +
    665 "   23           .   27            .   25            ;      1  1894.  - \n" +
    666 "\n" +
    667 "                  ( ,  1894;  ,  1894;  ,  1894).\n" +
    668 "\n" +
    669 " 24  1894      - .   1895     , , ,    .\n" +
    670 "\n" +
    671 "17  1895            .\n" +
    672 "\n" +
    673 "[]  \n" +
    674 "\n" +
    675 ",   ,     \" \" ,    - ,                    . 23  1895 ,    ,              ,          -,      II,   ,     -     .     ,    .\n" +
    676 "\n" +
    677 "  . 10  1895         , ,       30  .\n" +
    678 "\n" +
    679 "[]     \n" +
    680 "\n" +
    681 " 1895       150    4% .            ,       .   1895       - . 3  1896      -      . 8  1896      -           .       ,     .   1898    -     -   .\n" +
    682 "\n" +
    683 "[]   \n" +
    684 "\n" +
    685 "  1897   II   II         -    (    - \"-\"),    .          . 14  1897          . 6  1898    - ,         99 .                    .\n" +
    686 "\n" +
    687 "[]   \n" +
    688 "\n" +
    689 "    11  1898       (    )       .                  .       60 ,    ,   ,   ,   ,     ,   ,     ..     21    ,          .\n" +
    690 "\n" +
    691 "[] XX \n" +
    692 "\n" +
    693 "[]  \n" +
    694 "\n" +
    695 "  1900      ,      . 20        .        ,     .         ().    \"\" -,      222  . 21  1900      , , -, , , ,   .        .        . ,     ,            .    .\n" +
    696 "\n" +
    697 "[] - \n" +
    698 "\n" +
    699 "8  1904   -       . ,        ,   ,      -          .\n" +
    700 "\n" +
    701 "[]  \n" +
    702 "\n" +
    703 "14  1908          ,      . ,   ,     ,    .      ,    .      ,       .\n" +
    704 "\n" +
    705 "[]  \n" +
    706 "\n" +
    707 " 1910    ,        - .\n" +
    708 "\n" +
    709 "[]  1911     \n" +
    710 "\n" +
    711 " 1911      .      (19111913)  ,             .\n" +
    712 "\n" +
    713 "           . 3       .             .          .          .       ,        () .\n" +
    714 "\n" +
    715 "12  1912       .       -   .      .\n" +
    716 "\n" +
    717 " 1913   \" \".          .       ,    () .      .\n" +
    718 "\n" +
    719 "[]   \n" +
    720 "\n" +
    721 "                     ,      \"\"   .  22  1914            30-    -      .          ,         .\n" +
    722 "\n" +
    723 " 1915               .  .  .       .      ,   .   , ,   .\n" +
    724 "\n" +
    725 "22  1916    .\n" +
    726 "\n" +
    727 "[]  \n" +
    728 "\n" +
    729 "         -    .     (),    ()         ,       ,        .       ,    ,     -   .  -      :       ,        .\n" +
    730 "\n" +
    731 "      ,   ,    - , , , , , ,    .      ,  -   .     - . -        ,  -      .  1917        ,        ,      .\n" +
    732 "\n" +
    733 "[]  \n" +
    734 "\n" +
    735 "     1912    .    ,  1921 .,      ,         . 8  1923      ,            -  ,    ..,         .       . 20  1924 .  I     .            . 16         .      400,   - 500,   - 800   -  2600 ;       .         .   1924 .           .\n" +
    736 "  1926       ,    ,            .   ,            .\n" +
    737 "        :\n" +
    738 "\n" +
    739 "    *  . (    )\n" +
    740 "    *   \n" +
    741 "    * - \n" +
    742 "    *  \n" +
    743 "\n" +
    744 "         .          .\n" +
    745 " 1926 -          .                .\n" +
    746 "  1927           :         ,         .       1        ,      \" \".\n" +
    747 "  1927      ,          .\n" +
    748 "     1927        .\n" +
    749 "\n" +
    750 "[]      \n" +
    751 "\n" +
    752 " 1931    . 18        ,     .   1932       -,          ,     .\n" +
    753 "\n" +
    754 "            :   ,      ,    ,      .      ,         ,       .  1934         .         ,        -   .. \" \"     ;        \" \".         ,      ,             .   \" \"           .\n" +
    755 "\n" +
    756 "7  1937          .   ,    ,    .\n" +
    757 "\n" +
    758 "\n" +
    759 "      .    ,    .\n" +
    760 "  (1940)\n" +
    761 "  (1940)\n" +
    762 "\n" +
    763 "[]    \n" +
    764 "\n" +
    765 "    - 1945    ,     - .      .\n" +
    766 "     ,        .               .\n" +
    767 "  1945              - .      100   8-  4- .   ,           () -,    -  .\n" +
    768 "        1946.         ,      .  ,       1946   , ,   ,      ,     ,    .\n" +
    769 "        .                   30  1945.        100   .\n" +
    770 "  ,     ,         .           -  ,            ,             .\n" +
    771 "        :         ,    -      ,           ,          ,    .\n" +
    772 "    ,    ,      1948    600  .  1     4-  .    .\n" +
    773 "  1948 4-         .      52   ,  26 ,    ,    .   1949     ,     8-  . 15    , 22  - .\n" +
    774 "  1949               .     -     4- ,   .\n" +
    775 "24  1949             -  .          ,  ,         -    .\n" +
    776 "   -         ,         .\n" +
    777 "1  1949 .       .\n" +
    778 "               ,    .  ,   1949   -  -  ,        .\n" +
    779 "\n" +
    780 "[]  \n" +
    781 "\n" +
    782 " 1966                     .     ,  .        ,    ,     .\n" +
    783 "\n" +
    784 "[]  \n" +
    785 "\n" +
    786 "  \" \"          ,    1978    3-    11-   \"  \".   \" \"    XII   (1982 .).  XIII   (1987 .)        ,         -  , ..          ,      ,    \"-\".  XIV   (1992 .)            .       .: \"    - ,   \".\n" +
    787 "\n" +
    788 "  \" \"   \" \",        -             ,            .   70-     \"\" -       - \" \"  \" \".          800 .  (  ),               .                400 .   .                 .   800 .       .      ,       .         ,         .       -      (120 . .)     .         80-.               .\n" +
    789 "\n" +
    790 "     ,   1984       .           .        ()       .     \"   \" (\"    ,  \")          ,    .          .   - , , ,  -     .    14  ,        , -             .        ,       .                 ,       .          . ,            (),       (   : , , , , ).             (   20     200 . )    ,     48%  ,  - 38%, ,      , - 13,5%.       41%   ,  -  28%   - 31%.        90%,   - 80%,    - 85%.    ,      ,   95%  1978 .  5%   .   ,     ,      95  6%.       ,   ,  ,     .      20 ,   1985     9,5% .    1-      ,  ,  ,  ( 80 .),  (21,3 .),  (35 .), , , ,  , , ,  2- -  , 3- - ,  (7,3 ., . 4,6 . ), 4- - , 5- -  .       4-    (      -  2-).     5,4%    (2006 .).      2006 .   .      180 . . ,         ,          ,      2005   7600  (109-110      ).            2006 .  10000   .     100  150 .     ,      .      4,2% (2005 .).\n" +
    791 "\n" +
    792 "  21-     \" \"        ,    .          ,         .           ,      ,     \"\"    (   ).  -  -       (3,2 . /.  2005-, 2-   )         .\n" +
    793 "\n" +
    794 "              .    1997-  1999-    \"\"       ()   ().         ,       ,       .\n" +
    795 "\n" +
    796 "        .       ,      \"   \"   1989-,   ,  .            , ,       ,      .               .            ( 7000  ).     ,      .\n" +
    797 "\n" +
    798 "     ,       .        ,   ,      ,       ,       .\n" +
    799 "\n" +
    800 "[] . \n" +
    801 "\n" +
    802 "    *  ()\n" +
    803 "    *     1989 \n" +
    804 "\n" +
    805 "[] \n" +
    806 "\n" +
    807 "    *  ..  :  3 . . 3.   (VIII .  ..). .:  , 2006. ISBN 502018103X\n" +
    808 "    *  ..  :  . XVII   XX . .:  , 2005. ISBN 5020184004\n";
    809 
    810 var devanagari = 
    811 "\n" +
    812 ",    \n" +
    813 "Jump to: navigation, search\n" +
    814 "	                             \n" +
    815 " \n" +
    816 "Flag of  	Coat of arms of \n" +
    817 " 	\n" +
    818 ": \" \" ()\n" +
    819 "\n" +
    820 "    \n" +
    821 ":   \n" +
    822 "  \n" +
    823 " 	 \n" +
    824 ", ) 2834 N 7712 E\n" +
    825 "   	\n" +
    826 "() 	,     \n" +
    827 "\n" +
    828 "\n" +
    829 "\n" +
    830 "	\n" +
    831 " \n" +
    832 "  \n" +
    833 "   \n" +
    834 "	 , \n" +
    835 "\n" +
    836 " - \n" +
    837 " \n" +
    838 " -  (%) 	 \n" +
    839 ", ,  km ()\n" +
    840 ",, sq mi \n" +
    841 ".\n" +
    842 "\n" +
    843 " -  \n" +
    844 " -  \n" +
    845 " -    	 \n" +
    846 ",,,, ()\n" +
    847 ",,,,\n" +
    848 "/km ( )\n" +
    849 "/sq mi \n" +
    850 "   () ()\n" +
    851 " - \n" +
    852 " -  	 estimate\n" +
    853 "$.  ( GDP_PPP_per_capita = $,)\n" +
    854 "{{{GDP_PPP_per_capita}}} ( )\n" +
    855 "   () 	. ( )  medium\n" +
    856 " 	  ()\n" +
    857 " \n" +
    858 " -   (  ) 	 (UTC+:)\n" +
    859 "   (UTC+:)\n" +
    860 "    	.\n" +
    861 "  	+\n" +
    862 "\n" +
    863 " ,  ,                    8 4'  37 6'     68 7'  97 25'        ,,  . .  |        , . .      , . .        .    ,                  |      , -  , ,                   ,     -     -                                                   , , , , , , ,   \n" +
    864 "\n" +
    865 "    ( )   ,                        ( )        \n" +
    866 "\n" +
    867 "       ,         ,        ,         ( )                         -    ,               :  ,  ,        |                          ,       |         \n" +
    868 "\n" +
    869 "            (),  ()   () \n" +
    870 "\n" +
    871 "\n" +
    872 "\n" +
    873 "[]\n" +
    874 "\n" +
    875 "    *  \n" +
    876 "    *  \n" +
    877 "    *  \n" +
    878 "    *  \n" +
    879 "    *     \n" +
    880 "    *    \n" +
    881 "    *  \n" +
    882 "    *  \n" +
    883 "    *  \n" +
    884 "    *    \n" +
    885 "    *   \n" +
    886 "\n" +
    887 "[ ] \n" +
    888 " :    \n" +
    889 "\n" +
    890 "             (India)                  ,     ,           ( )                \n" +
    891 "\n" +
    892 "[ ] \n" +
    893 " :  \n" +
    894 "\n" +
    895 "                                  ,                                                                         \n" +
    896 "\n" +
    897 "    ,         ,      ,              ,      ,       , ,        |              ,   \" \" \n" +
    898 "             \n" +
    899 "             \n" +
    900 "\n" +
    901 "   -     , , ,     | , , , ,  ,  , ,        - |\n" +
    902 "\n" +
    903 "    ,      ,             ;   ,               ,    ,           \n" +
    904 "\n" +
    905 "     , , ,     ,        ,                                            ,           ,               \n" +
    906 "  -          ,            \n" +
    907 "  -          ,            \n" +
    908 "\n" +
    909 "                ,    ,              ,     -   ,   ,  , ,              15 , 1947           26 , 1950     \n" +
    910 "\n" +
    911 "          -                   -     ,     ,  -  ,            ,   \n" +
    912 "\n" +
    913 "                           ,  , ,           \n" +
    914 "\n" +
    915 "              \n" +
    916 "\n" +
    917 "              5                           \n" +
    918 "\n" +
    919 "[ ] \n" +
    920 " :  \n" +
    921 "\n" +
    922 "      , , ,           ,                  : ,   \n" +
    923 "\n" +
    924 ",     , has a largely ceremonial role.      ,   ()    ,                                                                               -      -      \n" +
    925 "\n" +
    926 "         -  , or Council of States,  .               ,         ,         ,                   \n" +
    927 "\n" +
    928 "     - ,                     ,     \n" +
    929 "\n" +
    930 "        ,                 ,         21   ,                       \n" +
    931 "\n" +
    932 "[ ] \n" +
    933 " :   \n" +
    934 "  \n" +
    935 "  \n" +
    936 "\n" +
    937 "                              ,       -         ,           ,                            -  \n" +
    938 "\n" +
    939 " ,    (),                                            ,           ()            -           ,                          \n" +
    940 "\n" +
    941 "                              ()             ()                                                 \n" +
    942 "\n" +
    943 "[ ]    \n" +
    944 " :   \n" +
    945 "\n" +
    946 "    ,                            ,       \n" +
    947 "\n" +
    948 "                       \n" +
    949 "\n" +
    950 "[ ]   \n" +
    951 " :   \n" +
    952 "                   \n" +
    953 "                   \n" +
    954 "\n" +
    955 "               ,            -    ,                             \n" +
    956 "\n" +
    957 "      , , ,                     \n" +
    958 "\n" +
    959 "                          ,                     \n" +
    960 "\n" +
    961 "     - , , , ,  (  ) |    -   \n" +
    962 "\n" +
    963 "[ ] \n" +
    964 " :   \n" +
    965 "  ()          ,   $  , ,         \n" +
    966 "  ()          ,   $  , ,         \n" +
    967 "\n" +
    968 "                         %                                                                                      ,                                 \n" +
    969 "\n" +
    970 "      [   ]]                            ()   %      , ,  , , ,   ,                     $      -                                                     \n" +
    971 "\n" +
    972 "                               .%   %         .              $            , ,     \n" +
    973 "\n" +
    974 "     , , ,    ,  ,  ,            , ,  ,              $        $    \n" +
    975 "\n" +
    976 "[ ] \n" +
    977 " :   \n" +
    978 "\n" +
    979 "                    ,   ,        \n" +
    980 "       -          \n" +
    981 "       -          \n" +
    982 "\n" +
    983 "  .      . %   .%                       (       ) .%       .%     .%       .         .      \n" +
    984 "\n" +
    985 "   .    , .                        (. %),  (. %),  (. %),  (. %),  (. %), , ,      \n" +
    986 "\n" +
    987 "    ,   ,     ( )                                                  \n" +
    988 "\n" +
    989 "[ ] \n" +
    990 " :  \n" +
    991 "          \n" +
    992 "          \n" +
    993 "\n" +
    994 "           ,                            , , -        ,        \n" +
    995 "                 \n" +
    996 "                 \n" +
    997 "\n" +
    998 "  ,   -              \n" +
    999 "\n" +
   1000 "             - , , .    . --, , ,      \n" +
   1001 "\n" +
   1002 "      ,        ,                 1983            2003          1930  40                            24-0                        \n" +
   1003 "\n" +
   1004 "                          \n" +
   1005 "\n" +
   1006 "                , ,                   \n" +
   1007 "\n" +
   1008 "                                                                                                                    \n" +
   1009 "\n" +
   1010 "[ ]   \n" +
   1011 "\n" +
   1012 "    *  \n" +
   1013 "    *   \n" +
   1014 "    *   \n" +
   1015 "\n" +
   1016 "\n" +
   1017 "[ ]  \n" +
   1018 "\n" +
   1019 " ()\n" +
   1020 "\n" +
   1021 "    *    \n" +
   1022 "\n" +
   1023 " ()\n" +
   1024 "\n" +
   1025 "    *     \n" +
   1026 "    *       \n" +
   1027 "\n" +
   1028 "  ()\n" +
   1029 "\n" +
   1030 "    *    \n" +
   1031 "    *     \n" +
   1032 "    *    \n" +
   1033 "\n" +
   1034 "   \n" +
   1035 "\n" +
   1036 "  ()\n" +
   1037 "\n" +
   1038 "    *       \n" +
   1039 "\n" +
   1040 " ()\n" +
   1041 "\n" +
   1042 "    *    \n" +
   1043 "    *     \n" +
   1044 "    *   -   \n";
   1045 
   1046 var english =
   1047 "English language\n" +
   1048 "From Wikipedia, the free encyclopedia\n" +
   1049 " Learn more about citing Wikipedia \n" +
   1050 "Jump to: navigation, search\n" +
   1051 "	Editing of this article by unregistered or newly registered users is currently disabled.\n" +
   1052 "If you cannot edit this article and you wish to make a change, you can discuss changes on the talk page, request unprotection, log in, or create an account.\n" +
   1053 "English  \n" +
   1054 "Pronunciation: 	/l/[37]\n" +
   1055 "Spoken in: 	Listed in the article\n" +
   1056 "Total speakers: 	First language: 309[38]  380 million[3]\n" +
   1057 "Second language: 199[39]  600 million[40]\n" +
   1058 "Overall: 1.8 billion[41] \n" +
   1059 "Ranking: 	3 (native speakers)[9][10]\n" +
   1060 "Total: 1 or 2 [11]\n" +
   1061 "Language family: 	Indo-European\n" +
   1062 " Germanic\n" +
   1063 "  West Germanic\n" +
   1064 "   AngloFrisian\n" +
   1065 "    Anglic\n" +
   1066 "     English \n" +
   1067 "Writing system: 	Latin (English variant) \n" +
   1068 "Official status\n" +
   1069 "Official language of: 	53 countries\n" +
   1070 "Flag of the United Nations United Nations\n" +
   1071 "Regulated by: 	no official regulation\n" +
   1072 "Language codes\n" +
   1073 "ISO 639-1: 	en\n" +
   1074 "ISO 639-2: 	eng\n" +
   1075 "ISO 639-3: 	eng \n" +
   1076 "World countries, states, and provinces where English is a primary language are dark blue; countries, states and provinces where it is an official but not a primary language are light blue. English is also one of the official languages of the European Union.\n" +
   1077 "Note: This page may contain IPA phonetic symbols in Unicode. See IPA chart for English for an English-based pronunciation key.\n" +
   1078 "\n" +
   1079 "English is a West Germanic language originating in England, and the first language for most people in Australia, Canada, the Commonwealth Caribbean, Ireland, New Zealand, the United Kingdom and the United States of America (also commonly known as the Anglosphere). It is used extensively as a second language and as an official language throughout the world, especially in Commonwealth countries such as India, Sri Lanka, Pakistan and South Africa, and in many international organisations.\n" +
   1080 "\n" +
   1081 "Modern English is sometimes described as the global lingua franca.[1][2] English is the dominant international language in communications, science, business, aviation, entertainment, radio and diplomacy.[3] The influence of the British Empire is the primary reason for the initial spread of the language far beyond the British Isles.[4] Following World War II, the growing economic and cultural influence of the United States has significantly accelerated the spread of the language.\n" +
   1082 "\n" +
   1083 "A working knowledge of English is required in certain fields, professions, and occupations. As a result over a billion people speak English at least at a basic level (see English language learning and teaching). English is one of six official languages of the United Nations.\n" +
   1084 "Contents\n" +
   1085 "[hide]\n" +
   1086 "\n" +
   1087 "    * 1 History\n" +
   1088 "    * 2 Classification and related languages\n" +
   1089 "    * 3 Geographical distribution\n" +
   1090 "          o 3.1 English as a global language\n" +
   1091 "          o 3.2 Dialects and regional varieties\n" +
   1092 "          o 3.3 Constructed varieties of English\n" +
   1093 "    * 4 Phonology\n" +
   1094 "          o 4.1 Vowels\n" +
   1095 "                + 4.1.1 See also\n" +
   1096 "          o 4.2 Consonants\n" +
   1097 "                + 4.2.1 Voicing and aspiration\n" +
   1098 "          o 4.3 Supra-segmental features\n" +
   1099 "                + 4.3.1 Tone groups\n" +
   1100 "                + 4.3.2 Characteristics of intonation\n" +
   1101 "    * 5 Grammar\n" +
   1102 "    * 6 Vocabulary\n" +
   1103 "          o 6.1 Number of words in English\n" +
   1104 "          o 6.2 Word origins\n" +
   1105 "                + 6.2.1 Dutch origins\n" +
   1106 "                + 6.2.2 French origins\n" +
   1107 "    * 7 Writing system\n" +
   1108 "          o 7.1 Basic sound-letter correspondence\n" +
   1109 "          o 7.2 Written accents\n" +
   1110 "    * 8 Formal written English\n" +
   1111 "    * 9 Basic and simplified versions\n" +
   1112 "    * 10 Notes\n" +
   1113 "    * 11 References\n" +
   1114 "    * 12 See also\n" +
   1115 "    * 13 External links\n" +
   1116 "          o 13.1 Dictionaries\n" +
   1117 "\n" +
   1118 "History\n" +
   1119 "\n" +
   1120 "    Main article: History of the English language\n" +
   1121 "\n" +
   1122 "English is an Anglo-Frisian language. Germanic-speaking peoples from northwest Germany (Saxons and Angles) and Jutland (Jutes) invaded what is now known as Eastern England around the fifth century AD. It is a matter of debate whether the Old English language spread by displacement of the original population, or the native Celts gradually adopted the language and culture of a new ruling class, or a combination of both of these processes (see Sub-Roman Britain).\n" +
   1123 "\n" +
   1124 "Whatever their origin, these Germanic dialects eventually coalesced to a degree (there remained geographical variation) and formed what is today called Old English. Old English loosely resembles some coastal dialects in what are now northwest Germany and the Netherlands (i.e., Frisia). Throughout the history of written Old English, it retained a synthetic structure closer to that of Proto-Indo-European, largely adopting West Saxon scribal conventions, while spoken Old English became increasingly analytic in nature, losing the more complex noun case system, relying more heavily on prepositions and fixed word order to convey meaning. This is evident in the Middle English period, when literature was to an increasing extent recorded with spoken dialectal variation intact, after written Old English lost its status as the literary language of the nobility. It is postulated that the early development of the language was influenced by a Celtic substratum.[5][6] Later, it was influenced by the related North Germanic language Old Norse, spoken by the Vikings who settled mainly in the north and the east coast down to London, the area known as the Danelaw.\n" +
   1125 "\n" +
   1126 "The Norman Conquest of England in 1066 profoundly influenced the evolution of the language. For about 300 years after this, the Normans used Anglo-Norman, which was close to Old French, as the language of the court, law and administration. By the fourteenth century, Anglo-Norman borrowings had contributed roughly 10,000 words to English, of which 75% remain in use. These include many words pertaining to the legal and administrative fields, but also include common words for food, such as mutton[7] and beef[8]. The Norman influence gave rise to what is now referred to as Middle English. Later, during the English Renaissance, many words were borrowed directly from Latin (giving rise to a number of doublets) and Greek, leaving a parallel vocabulary that persists into modern times. By the seventeenth century there was a reaction in some circles against so-called inkhorn terms.\n" +
   1127 "\n" +
   1128 "During the fifteenth century, Middle English was transformed by the Great Vowel Shift, the spread of a prestigious South Eastern-based dialect in the court, administration and academic life, and the standardising effect of printing. Early Modern English can be traced back to around the Elizabethan period.\n" +
   1129 "\n" +
   1130 "Classification and related languages\n" +
   1131 "\n" +
   1132 "The English language belongs to the western sub-branch of the Germanic branch of the Indo-European family of languages.\n" +
   1133 "\n" +
   1134 "The question as to which is the nearest living relative of English is a matter of discussion. Apart from such English-lexified creole languages such as Tok Pisin, Scots (spoken primarily in Scotland and parts of Northern Ireland) is not a Gaelic language, but is part of the English family of languages: both Scots and modern English are descended from Old English, also known as Anglo-Saxon. The closest relative to English after Scots is Frisian, which is spoken in the Northern Netherlands and Northwest Germany. Other less closely related living West Germanic languages include German, Low Saxon, Dutch, and Afrikaans. The North Germanic languages of Scandinavia are less closely related to English than the West Germanic languages.\n" +
   1135 "\n" +
   1136 "Many French words are also intelligible to an English speaker (though pronunciations are often quite different) because English absorbed a large vocabulary from Norman and French, via Anglo-Norman after the Norman Conquest and directly from French in subsequent centuries. As a result, a large portion of English vocabulary is derived from French, with some minor spelling differences (word endings, use of old French spellings, etc.), as well as occasional divergences in meaning, in so-called \"faux amis\", or false friends.\n" +
   1137 "\n" +
   1138 "Geographical distribution\n" +
   1139 "\n" +
   1140 "    See also: List of countries by English-speaking population\n" +
   1141 "\n" +
   1142 "Over 380 million people speak English as their first language. English today is probably the third largest language by number of native speakers, after Mandarin Chinese and Spanish.[9][10] However, when combining native and non-native speakers it is probably the most commonly spoken language in the world, though possibly second to a combination of the Chinese Languages, depending on whether or not distinctions in the latter are classified as \"languages\" or \"dialects.\"[11][12] Estimates that include second language speakers vary greatly from 470 million to over a billion depending on how literacy or mastery is defined.[13][14] There are some who claim that non-native speakers now outnumber native speakers by a ratio of 3 to 1.[15]\n" +
   1143 "\n" +
   1144 "The countries with the highest populations of native English speakers are, in descending order: United States (215 million),[16] United Kingdom (58 million),[17] Canada (17.7 million),[18] Australia (15 million),[19] Ireland (3.8 million),[17] South Africa (3.7 million),[20] and New Zealand (3.0-3.7 million).[21] Countries such as Jamaica and Nigeria also have millions of native speakers of dialect continuums ranging from an English-based creole to a more standard version of English. Of those nations where English is spoken as a second language, India has the most such speakers ('Indian English') and linguistics professor David Crystal claims that, combining native and non-native speakers, India now has more people who speak or understand English than any other country in the world.[22] Following India is the People's Republic of China.[23]\n" +
   1145 "Distribution of native English speakers by country (Crystal 1997)\n" +
   1146 "Distribution of native English speakers by country (Crystal 1997)\n" +
   1147 "	Country 	Native speakers\n" +
   1148 "1 	USA 	214,809,000[16]\n" +
   1149 "2 	UK 	58,200,000[17]\n" +
   1150 "3 	Canada 	17,694,830[18]\n" +
   1151 "4 	Australia 	15,013,965[19]\n" +
   1152 "5 	Ireland 	4,200,000+ (Approx)[17]\n" +
   1153 "6 	South Africa 	3,673,203[20]\n" +
   1154 "7 	New Zealand 	3,500,000+ (Approx)[21]\n" +
   1155 "8 	Singapore 	665,087[24]\n" +
   1156 "\n" +
   1157 "English is the primary language in Anguilla, Antigua and Barbuda, Australia (Australian English), the Bahamas, Barbados, Bermuda, Belize, the British Indian Ocean Territory, the British Virgin Islands, Canada (Canadian English), the Cayman Islands, Dominica, the Falkland Islands, Gibraltar, Grenada, Guernsey (Guernsey English), Guyana, Ireland (Hiberno-English), Isle of Man (Manx English), Jamaica (Jamaican English), Jersey, Montserrat, Nauru, New Zealand (New Zealand English), Pitcairn Islands, Saint Helena, Saint Lucia, Saint Kitts and Nevis, Saint Vincent and the Grenadines, Singapore, South Georgia and the South Sandwich Islands, Trinidad and Tobago, the Turks and Caicos Islands, the United Kingdom, the U.S. Virgin Islands, and the United States (various forms of American English).\n" +
   1158 "\n" +
   1159 "In many other countries, where English is not the most spoken language, it is an official language; these countries include Botswana, Cameroon, Fiji, the Federated States of Micronesia, Ghana, Gambia, Hong Kong, India, Kiribati, Lesotho, Liberia, Kenya, Madagascar, Malta, the Marshall Islands, Namibia, Nigeria, Pakistan, Papua New Guinea, the Philippines, Puerto Rico, Rwanda, the Solomon Islands, Samoa, Sierra Leone, Singapore, Sri Lanka, Swaziland, Tanzania, Uganda, Zambia, and Zimbabwe. It is also one of the 11 official languages that are given equal status in South Africa (\"South African English\"). English is also an important language in several former colonies or current dependent territories of the United Kingdom and the United States, such as in Hong Kong and Mauritius.\n" +
   1160 "\n" +
   1161 "English is not an official language in either the United States or the United Kingdom.[25][26] Although the United States federal government has no official languages, English has been given official status by 30 of the 50 state governments.[27]\n" +
   1162 "\n" +
   1163 "English as a global language\n" +
   1164 "\n" +
   1165 "    See also: English on the Internet and global language\n" +
   1166 "\n" +
   1167 "Because English is so widely spoken, it has often been referred to as a \"global language\", the lingua franca of the modern era.[2] While English is not an official language in many countries, it is currently the language most often taught as a second language around the world. Some linguists believe that it is no longer the exclusive cultural sign of \"native English speakers\", but is rather a language that is absorbing aspects of cultures worldwide as it continues to grow. It is, by international treaty, the official language for aerial and maritime communications, as well as one of the official languages of the European Union, the United Nations, and most international athletic organisations, including the International Olympic Committee.\n" +
   1168 "\n" +
   1169 "English is the language most often studied as a foreign language in the European Union (by 89% of schoolchildren), followed by French (32%), German (18%), and Spanish (8%).[28] In the EU, a large fraction of the population reports being able to converse to some extent in English. Among non-English speaking countries, a large percentage of the population claimed to be able to converse in English in the Netherlands (87%), Sweden (85%), Denmark (83%), Luxembourg (66%), Finland (60%), Slovenia (56%), Austria (53%), Belgium (52%), and Germany (51%). [29] Norway and Iceland also have a large majority of competent English-speakers.\n" +
   1170 "\n" +
   1171 "Books, magazines, and newspapers written in English are available in many countries around the world. English is also the most commonly used language in the sciences.[2] In 1997, the Science Citation Index reported that 95% of its articles were written in English, even though only half of them came from authors in English-speaking countries.\n" +
   1172 "\n" +
   1173 "Dialects and regional varieties\n" +
   1174 "\n" +
   1175 "    Main article: List of dialects of the English language\n" +
   1176 "\n" +
   1177 "The expansion of the British Empire andsince WWIIthe primacy of the United States have spread English throughout the globe.[2] Because of that global spread, English has developed a host of English dialects and English-based creole languages and pidgins.\n" +
   1178 "\n" +
   1179 "The major varieties of English include, in most cases, several subvarieties, such as Cockney slang within British English; Newfoundland English within Canadian English; and African American Vernacular English (\"Ebonics\") and Southern American English within American English. English is a pluricentric language, without a central language authority like France's Acadmie franaise; and, although no variety is clearly considered the only standard, there are a number of accents considered to be more prestigious, such as Received Pronunciation in Britain.\n" +
   1180 "\n" +
   1181 "Scots developed  largely independently  from the same origins, but following the Acts of Union 1707 a process of language attrition began, whereby successive generations adopted more and more features from English causing dialectalisation. Whether it is now a separate language or a dialect of English better described as Scottish English is in dispute. The pronunciation, grammar and lexis of the traditional forms differ, sometimes substantially, from other varieties of English.\n" +
   1182 "\n" +
   1183 "Because of the wide use of English as a second language, English speakers have many different accents, which often signal the speaker's native dialect or language. For the more distinctive characteristics of regional accents, see Regional accents of English speakers, and for the more distinctive characteristics of regional dialects, see List of dialects of the English language.\n" +
   1184 "\n" +
   1185 "Just as English itself has borrowed words from many different languages over its history, English loanwords now appear in a great many languages around the world, indicative of the technological and cultural influence of its speakers. Several pidgins and creole languages have formed using an English base, such as Jamaican Creole, Nigerian Pidgin, and Tok Pisin. There are many words in English coined to describe forms of particular non-English languages that contain a very high proportion of English words. Franglais, for example, is used to describe French with a very high English word content; it is found on the Channel Islands. Another variant, spoken in the border bilingual regions of Qubec in Canada, is called FrEnglish.\n" +
   1186 "\n" +
   1187 "Constructed varieties of English\n" +
   1188 "\n" +
   1189 "    * Basic English is simplified for easy international use. It is used by manufacturers and other international businesses to write manuals and communicate. Some English schools in Asia teach it as a practical subset of English for use by beginners.\n" +
   1190 "    * Special English is a simplified version of English used by the Voice of America. It uses a vocabulary of only 1500 words.\n" +
   1191 "    * English reform is an attempt to improve collectively upon the English language.\n" +
   1192 "    * Seaspeak and the related Airspeak and Policespeak, all based on restricted vocabularies, were designed by Edward Johnson in the 1980s to aid international cooperation and communication in specific areas. There is also a tunnelspeak for use in the Channel Tunnel.\n" +
   1193 "    * English as a lingua franca for Europe and Euro-English are concepts of standardising English for use as a second language in continental Europe.\n" +
   1194 "    * Manually Coded English  a variety of systems have been developed to represent the English language with hand signals, designed primarily for use in deaf education. These should not be confused with true sign languages such as British Sign Language and American Sign Language used in Anglophone countries, which are independent and not based on English.\n" +
   1195 "    * E-Prime excludes forms of the verb to be.\n" +
   1196 "\n" +
   1197 "Euro-English (also EuroEnglish or Euro-English) terms are English translations of European concepts that are not native to English-speaking countries. Due to the United Kingdom's (and even the Republic of Ireland's) involvement in the European Union, the usage focuses on non-British concepts. This kind of Euro-English was parodied when English was \"made\" one of the constituent languages of Europanto.\n" +
   1198 "\n" +
   1199 "Phonology\n" +
   1200 "\n" +
   1201 "    Main article: English phonology\n" +
   1202 "\n" +
   1203 "Vowels\n" +
   1204 "IPA 	Description 	word\n" +
   1205 "monophthongs\n" +
   1206 "i/i 	Close front unrounded vowel 	bead\n" +
   1207 " 	Near-close near-front unrounded vowel 	bid\n" +
   1208 " 	Open-mid front unrounded vowel 	bed\n" +
   1209 " 	Near-open front unrounded vowel 	bad\n" +
   1210 " 	Open back rounded vowel 	bod 1\n" +
   1211 " 	Open-mid back rounded vowel 	pawed 2\n" +
   1212 "/ 	Open back unrounded vowel 	bra\n" +
   1213 " 	Near-close near-back rounded vowel 	good\n" +
   1214 "u/u 	Close back rounded vowel 	booed\n" +
   1215 "/ 	Open-mid back unrounded vowel, Near-open central vowel 	bud\n" +
   1216 "/ 	Open-mid central unrounded vowel 	bird 3\n" +
   1217 " 	Schwa 	Rosa's 4\n" +
   1218 " 	Close central unrounded vowel 	roses 5\n" +
   1219 "diphthongs\n" +
   1220 "e()/e 	Close-mid front unrounded vowel\n" +
   1221 "Close front unrounded vowel 	bayed 6\n" +
   1222 "o()/ 	Close-mid back rounded vowel\n" +
   1223 "Near-close near-back rounded vowel 	bode 6\n" +
   1224 "a 	Open front unrounded vowel\n" +
   1225 "Near-close near-front unrounded vowel 	cry\n" +
   1226 "a 	Open front unrounded vowel\n" +
   1227 "Near-close near-back rounded vowel 	bough\n" +
   1228 " 	Open-mid back rounded vowel\n" +
   1229 "Close front unrounded vowel 	boy\n" +
   1230 "/ 	Near-close near-back rounded vowel\n" +
   1231 "Schwa 	boor 9\n" +
   1232 "/ 	Open-mid front unrounded vowel\n" +
   1233 "Schwa 	fair 10\n" +
   1234 "\n" +
   1235 "Notes:\n" +
   1236 "\n" +
   1237 "It is the vowels that differ most from region to region.\n" +
   1238 "\n" +
   1239 "Where symbols appear in pairs, the first corresponds to American English, General American accent; the second corresponds to British English, Received Pronunciation.\n" +
   1240 "\n" +
   1241 "   1. American English lacks this sound; words with this sound are pronounced with // or //.\n" +
   1242 "   2. Many dialects of North American English do not have this vowel. See Cot-caught merger.\n" +
   1243 "   3. The North American variation of this sound is a rhotic vowel.\n" +
   1244 "   4. Many speakers of North American English do not distinguish between these two unstressed vowels. For them, roses and Rosa's are pronounced the same, and the symbol usually used is schwa //.\n" +
   1245 "   5. This sound is often transcribed with /i/ or with //.\n" +
   1246 "   6. The diphthongs /e/ and /o/ are monophthongal for many General American speakers, as /e/ and /o/.\n" +
   1247 "   7. The letter <U> can represent either /u/ or the iotated vowel /ju/. In BRP, if this iotated vowel /ju/ occurs after /t/, /d/, /s/ or /z/, it often triggers palatalization of the preceding consonant, turning it to //, //, // and // respectively, as in tune, during, sugar, and azure. In American English, palatalization does not generally happen unless the /ju/ is followed by r, with the result that /(t, d,s, z)jur/ turn to /t/, /d/, // and // respectively, as in nature, verdure, sure, and treasure.\n" +
   1248 "   8. Vowel length plays a phonetic role in the majority of English dialects, and is said to be phonemic in a few dialects, such as Australian English and New Zealand English. In certain dialects of the modern English language, for instance General American, there is allophonic vowel length: vowel phonemes are realized as long vowel allophones before voiced consonant phonemes in the coda of a syllable. Before the Great Vowel Shift, vowel length was phonemically contrastive.\n" +
   1249 "   9. This sound only occurs in non-rhotic accents. In some accents, this sound may be, instead of //, /:/. See pour-poor merger.\n" +
   1250 "  10. This sound only occurs in non-rhotic accents. In some accents, the schwa offglide of // may be dropped, monophthising and lengthening the sound to /:/.\n" +
   1251 "\n" +
   1252 "See also\n" +
   1253 "\n" +
   1254 "    * International Phonetic Alphabet for English for more vowel charts.\n" +
   1255 "\n" +
   1256 "Consonants\n" +
   1257 "\n" +
   1258 "This is the English Consonantal System using symbols from the International Phonetic Alphabet (IPA).\n" +
   1259 "  	bilabial 	labio-\n" +
   1260 "dental 	dental 	alveolar 	post-\n" +
   1261 "alveolar 	palatal 	velar 	glottal\n" +
   1262 "plosive 	p  b 	  	  	t  d 	  	  	k   	 \n" +
   1263 "nasal 	m 	  	  	n 	  	  	 1 	 \n" +
   1264 "flap 	  	  	  	 2 	  	  	  	 \n" +
   1265 "fricative 	  	f  v 	   3 	s  z 	   4 	 5 	x 6 	h\n" +
   1266 "affricate 	  	  	  	  	t  d 4 	  	  	 \n" +
   1267 "approximant 	  	  	  	 4 	  	j 	  	 \n" +
   1268 "lateral approximant 	  	  	  	l 	  	  	  	 \n" +
   1269 "  	labial-velar\n" +
   1270 "approximant 	  w 7\n" +
   1271 "\n" +
   1272 "   1. The velar nasal [] is a non-phonemic allophone of /n/ in some northerly British accents, appearing only before /k/ and /g/. In all other dialects it is a separate phoneme, although it only occurs in syllable codas.\n" +
   1273 "   2. The alveolar flap [] is an allophone of /t/ and /d/ in unstressed syllables in North American English and Australian English.[30] This is the sound of tt or dd in the words latter and ladder, which are homophones for many speakers of North American English. In some accents such as Scottish English and Indian English it replaces //. This is the same sound represented by single r in most varieties of Spanish.\n" +
   1274 "   3. In some dialects, such as Cockney, the interdentals // and // are usually merged with /f/ and /v/, and in others, like African American Vernacular English, // is merged with dental /d/. In some Irish varieties, // and // become the corresponding dental plosives, which then contrast with the usual alveolar plosives.\n" +
   1275 "   4. The sounds //, //, and // are labialised in some dialects. Labialisation is never contrastive in initial position and therefore is sometimes not transcribed. Most speakers of General American realize <r> (always rhoticized) as the retroflex approximant //, whereas the same is realized in Scottish English, etc. as the alveolar trill.\n" +
   1276 "   5. The voiceless palatal fricative // is in most accents just an allophone of /h/ before /j/; for instance human /jumn/. However, in some accents (see this), the /j/ is dropped, but the initial consonant is the same.\n" +
   1277 "   6. The voiceless velar fricative /x/ is used only by Scottish or Welsh speakers of English for Scots/Gaelic words such as loch /lx/ or by some speakers for loanwords from German and Hebrew like Bach /bax/ or Chanukah /xanuka/. In some dialects such as Scouse (Liverpool) either [x] or the affricate [kx] may be used as an allophone of /k/ in words such as docker [dkx]. Most native speakers have a great deal of trouble pronouncing it correctly when learning a foreign language. Most speakers use the sounds [k] and [h] instead.\n" +
   1278 "   7. Voiceless w [] is found in Scottish and Irish English, as well as in some varieties of American, New Zealand, and English English. In most other dialects it is merged with /w/, in some dialects of Scots it is merged with /f/.\n" +
   1279 "\n" +
   1280 "Voicing and aspiration\n" +
   1281 "\n" +
   1282 "Voicing and aspiration of stop consonants in English depend on dialect and context, but a few general rules can be given:\n" +
   1283 "\n" +
   1284 "    * Voiceless plosives and affricates (/ p/, / t/, / k/, and / t/) are aspirated when they are word-initial or begin a stressed syllable  compare pin [pn] and spin [spn], crap [kp] and scrap [skp].\n" +
   1285 "          o In some dialects, aspiration extends to unstressed syllables as well.\n" +
   1286 "          o In other dialects, such as Indo-Pakistani English, all voiceless stops remain unaspirated.\n" +
   1287 "    * Word-initial voiced plosives may be devoiced in some dialects.\n" +
   1288 "    * Word-terminal voiceless plosives may be unreleased or accompanied by a glottal stop in some dialects (e.g. many varieties of American English)  examples: tap [tp], sack [sk].\n" +
   1289 "    * Word-terminal voiced plosives may be devoiced in some dialects (e.g. some varieties of American English)  examples: sad [sd], bag [b]. In other dialects they are fully voiced in final position, but only partially voiced in initial position.\n" +
   1290 "\n" +
   1291 "Supra-segmental features\n" +
   1292 "\n" +
   1293 "Tone groups\n" +
   1294 "\n" +
   1295 "English is an intonation language. This means that the pitch of the voice is used syntactically, for example, to convey surprise and irony, or to change a statement into a question.\n" +
   1296 "\n" +
   1297 "In English, intonation patterns are on groups of words, which are called tone groups, tone units, intonation groups or sense groups. Tone groups are said on a single breath and, as a consequence, are of limited length, more often being on average five words long or lasting roughly two seconds. For example:\n" +
   1298 "\n" +
   1299 "    - /du ju nid n/ Do you need anything?\n" +
   1300 "    - /a dnt | n/ I don't, no\n" +
   1301 "    - /a dnt n/ I don't know (contracted to, for example, - /a dn/ or /a dn/ I dunno in fast or colloquial speech that de-emphasises the pause between don't and know even further)\n" +
   1302 "\n" +
   1303 "Characteristics of intonation\n" +
   1304 "\n" +
   1305 "English is a strongly stressed language, in that certain syllables, both within words and within phrases, get a relative prominence/loudness during pronunciation while the others do not. The former kind of syllables are said to be accentuated/stressed and the latter are unaccentuated/unstressed. All good dictionaries of English mark the accentuated syllable(s) by either placing an apostrophe-like (  ) sign either before (as in IPA, Oxford English Dictionary, or Merriam-Webster dictionaries) or after (as in many other dictionaries) the syllable where the stress accent falls. In general, for a two-syllable word in English, it can be broadly said that if it is a noun or an adjective, the first syllable is accentuated; but if it is a verb, the second syllable is accentuated.\n" +
   1306 "\n" +
   1307 "Hence in a sentence, each tone group can be subdivided into syllables, which can either be stressed (strong) or unstressed (weak). The stressed syllable is called the nuclear syllable. For example:\n" +
   1308 "\n" +
   1309 "    That | was | the | best | thing | you | could | have | done!\n" +
   1310 "\n" +
   1311 "Here, all syllables are unstressed, except the syllables/words best and done, which are stressed. Best is stressed harder and, therefore, is the nuclear syllable.\n" +
   1312 "\n" +
   1313 "The nuclear syllable carries the main point the speaker wishes to make. For example:\n" +
   1314 "\n" +
   1315 "    John hadn't stolen that money. (... Someone else had.)\n" +
   1316 "    John hadn't stolen that money. (... You said he had. or ... Not at that time, but later he did.)\n" +
   1317 "    John hadn't stolen that money. (... He acquired the money by some other means.)\n" +
   1318 "    John hadn't stolen that money. (... He had stolen some other money.)\n" +
   1319 "    John hadn't stolen that money. (... He stole something else.)\n" +
   1320 "\n" +
   1321 "Also\n" +
   1322 "\n" +
   1323 "    I didn't tell her that. (... Someone else told her.)\n" +
   1324 "    I didn't tell her that. (... You said I did. or ... But now I will!)\n" +
   1325 "    I didn't tell her that. (... I didn't say it; she could have inferred it, etc.)\n" +
   1326 "    I didn't tell her that. (... I told someone else.)\n" +
   1327 "    I didn't tell her that. (... I told her something else.)\n" +
   1328 "\n" +
   1329 "This can also be used to express emotion:\n" +
   1330 "\n" +
   1331 "    Oh really? (...I didn't know that)\n" +
   1332 "    Oh really? (...I disbelieve you)\n" +
   1333 "\n" +
   1334 "The nuclear syllable is spoken more loudly than the others and has a characteristic change of pitch. The changes of pitch most commonly encountered in English are the rising pitch and the falling pitch, although the fall-rising pitch and/or the rise-falling pitch are sometimes used. In this opposition between falling and rising pitch, which plays a larger role in English than in most other languages, falling pitch conveys certainty and rising pitch uncertainty. This can have a crucial impact on meaning, specifically in relation to polarity, the positivenegative opposition; thus, falling pitch means \"polarity known\", while rising pitch means \"polarity unknown\". This underlies the rising pitch of yes/no questions. For example:\n" +
   1335 "\n" +
   1336 "    When do you want to be paid?\n" +
   1337 "    Now? (Rising pitch. In this case, it denotes a question: \"Can I be paid now?\" or \"Do you desire to be paid now?\")\n" +
   1338 "    Now. (Falling pitch. In this case, it denotes a statement: \"I choose to be paid now.\")\n" +
   1339 "\n" +
   1340 "Grammar\n" +
   1341 "\n" +
   1342 "    Main article: English grammar\n" +
   1343 "\n" +
   1344 "English grammar has minimal inflection compared with most other Indo-European languages. For example, Modern English, unlike Modern German or Dutch and the Romance languages, lacks grammatical gender and adjectival agreement. Case marking has almost disappeared from the language and mainly survives in pronouns. The patterning of strong (e.g. speak/spoke/spoken) versus weak verbs inherited from its Germanic origins has declined in importance in modern English, and the remnants of inflection (such as plural marking) have become more regular.\n" +
   1345 "\n" +
   1346 "At the same time, the language has become more analytic, and has developed features such as modal verbs and word order as rich resources for conveying meaning. Auxiliary verbs mark constructions such as questions, negative polarity, the passive voice and progressive tenses.\n" +
   1347 "\n" +
   1348 "Vocabulary\n" +
   1349 "\n" +
   1350 "The English vocabulary has changed considerably over the centuries.[31]\n" +
   1351 "\n" +
   1352 "Germanic words (generally words of Old English or to a lesser extent Norse origin) which include all the basics such as pronouns (I, my, you, it) and conjunctions (and, or, but) tend to be shorter than the Latinate words of English, and more common in ordinary speech. The longer Latinate words are often regarded as more elegant or educated. However, the excessive or superfluous use of Latinate words is considered at times to be either pretentious (as in the stereotypical policeman's talk of \"apprehending the suspect\") or an attempt to obfuscate an issue. George Orwell's essay \"Politics and the English Language\" is critical of this, as well as other perceived abuses of the language.\n" +
   1353 "\n" +
   1354 "An English speaker is in many cases able to choose between Germanic and Latinate synonyms: come or arrive; sight or vision; freedom or liberty. In some cases there is a choice between a Germanic derived word (oversee), a Latin derived word (supervise), and a French word derived from the same Latin word (survey). The richness of the language arises from the variety of different meanings and nuances such synonyms harbour, enabling the speaker to express fine variations or shades of thought. Familiarity with the etymology of groups of synonyms can give English speakers greater control over their linguistic register. See: List of Germanic and Latinate equivalents.\n" +
   1355 "\n" +
   1356 "An exception to this and a peculiarity perhaps unique to English is that the nouns for meats are commonly different from, and unrelated to, those for the animals from which they are produced, the animal commonly having a Germanic name and the meat having a French-derived one. Examples include: deer and venison; cow and beef; swine/pig and pork, or sheep and mutton. This is assumed to be a result of the aftermath of the Norman invasion, where a French-speaking elite were the consumers of the meat, produced by English-speaking lower classes.\n" +
   1357 "\n" +
   1358 "In everyday speech, the majority of words will normally be Germanic. If a speaker wishes to make a forceful point in an argument in a very blunt way, Germanic words will usually be chosen. A majority of Latinate words (or at least a majority of content words) will normally be used in more formal speech and writing, such as a courtroom or an encyclopedia article. However, there are other Latinate words that are used normally in everyday speech and do not sound formal; these are mainly words for concepts that no longer have Germanic words, and are generally assimilated better and in many cases do not appear Latinate. For instance, the words mountain, valley, river, aunt, uncle, move, use, push and stay are all Latinate.\n" +
   1359 "\n" +
   1360 "English is noted for the vast size of its active vocabulary and its fluidity.[citation needed][weasel words] English easily accepts technical terms into common usage and imports new words and phrases that often come into common usage. Examples of this phenomenon include: cookie, Internet and URL (technical terms), as well as genre, ber, lingua franca and amigo (imported words/phrases from French, German, modern Latin, and Spanish, respectively). In addition, slang often provides new meanings for old words and phrases. In fact, this fluidity is so pronounced that a distinction often needs to be made between formal forms of English and contemporary usage. See also: sociolinguistics.\n" +
   1361 "\n" +
   1362 "Number of words in English\n" +
   1363 "\n" +
   1364 "English has an extraordinarily rich vocabulary and willingness to absorb new words. As the General Explanations at the beginning of the Oxford English Dictionary states:\n" +
   1365 "\n" +
   1366 "    The Vocabulary of a widely diffused and highly cultivated living language is not a fixed quantity circumscribed by definite limits... there is absolutely no defining line in any direction: the circle of the English language has a well-defined centre but no discernible circumference.\n" +
   1367 "\n" +
   1368 "The vocabulary of English is undoubtedly vast, but assigning a specific number to its size is more a matter of definition than of calculation. Unlike other languages, there is no Academy to define officially accepted words. Neologisms are coined regularly in medicine, science and technology and other fields, and new slang is constantly developed. Some of these new words enter wide usage; others remain restricted to small circles. Foreign words used in immigrant communities often make their way into wider English usage. Archaic, dialectal, and regional words might or might not be widely considered as \"English\".\n" +
   1369 "\n" +
   1370 "The Oxford English Dictionary, 2nd edition (OED2) includes over 600,000 definitions, following a rather inclusive policy:\n" +
   1371 "\n" +
   1372 "    It embraces not only the standard language of literature and conversation, whether current at the moment, or obsolete, or archaic, but also the main technical vocabulary, and a large measure of dialectal usage and slang (Supplement to the OED, 1933).[32]\n" +
   1373 "\n" +
   1374 "The editors of Webster's Third New International Dictionary, Unabridged (475,000 main headwords) in their preface, estimate the number to be much higher. It is estimated that about 25,000 words are added to the language each year.[33]\n" +
   1375 "\n" +
   1376 "Word origins\n" +
   1377 "Influences in English vocabulary\n" +
   1378 "Influences in English vocabulary\n" +
   1379 "\n" +
   1380 "    Main article: Lists of English words of international origin\n" +
   1381 "\n" +
   1382 "One of the consequences of the French influence is that the vocabulary of English is, to a certain extent, divided between those words which are Germanic (mostly Old English) and those which are \"Latinate\" (Latin-derived, either directly from Norman French or other Romance languages).\n" +
   1383 "\n" +
   1384 "Numerous sets of statistics have been proposed to demonstrate the various origins of English vocabulary. None, as yet, are considered definitive by a majority of linguists.\n" +
   1385 "\n" +
   1386 "A computerised survey of about 80,000 words in the old Shorter Oxford Dictionary (3rd ed.) was published in Ordered Profusion by Thomas Finkenstaedt and Dieter Wolff (1973)[34] that estimated the origin of English words as follows:\n" +
   1387 "\n" +
   1388 "    * Langue d'ol, including French and Old Norman: 28.3%\n" +
   1389 "    * Latin, including modern scientific and technical Latin: 28.24%\n" +
   1390 "    * Other Germanic languages (including words directly inherited from Old English): 25%\n" +
   1391 "    * Greek: 5.32%\n" +
   1392 "    * No etymology given: 4.03%\n" +
   1393 "    * Derived from proper names: 3.28%\n" +
   1394 "    * All other languages contributed less than 1% (e.g. Arabic-English loanwords)\n" +
   1395 "\n" +
   1396 "A survey by Joseph M. Williams in Origins of the English Language of 10,000 words taken from several thousand business letters[35] gave this set of statistics:\n" +
   1397 "\n" +
   1398 "    * French (langue d'ol), 41%\n" +
   1399 "    * \"Native\" English, 33%\n" +
   1400 "    * Latin, 15%\n" +
   1401 "    * Danish, 2%\n" +
   1402 "    * Dutch, 1%\n" +
   1403 "    * Other, 10%\n" +
   1404 "\n" +
   1405 "However, 83% of the 1,000 most-common English words are Anglo-Saxon in origin. [36]\n" +
   1406 "\n" +
   1407 "Dutch origins\n" +
   1408 "\n" +
   1409 "    Main article: List of English words of Dutch origin\n" +
   1410 "\n" +
   1411 "Words describing the navy, types of ships, and other objects or activities on the water are often from Dutch origin. Yacht (Jacht) and cruiser (kruiser) are examples.\n" +
   1412 "\n" +
   1413 "French origins\n" +
   1414 "\n" +
   1415 "    Main article: List of French phrases used by English speakers\n" +
   1416 "\n" +
   1417 "There are many words of French origin in English, such as competition, art, table, publicity, police, role, routine, machine, force, and many others that have been and are being anglicised; they are now pronounced according to English rules of phonology, rather than French. A large portion of English vocabulary is of French or Ol language origin, most derived from, or transmitted via, the Anglo-Norman spoken by the upper classes in England for several hundred years after the Norman Conquest.\n";
   1418 
   1419 
   1420 var greek = 
   1421 "\n" +
   1422 "  ,   \n" +
   1423 " \n" +
   1424 "	\n" +
   1425 "	\n" +
   1426 " :   \n" +
   1427 " :    \n" +
   1428 "\n" +
   1429 "	 \n" +
   1430 "38.01.36N 23.44.00E\n" +
   1431 "\n" +
   1432 " 	\n" +
   1433 " 	\n" +
   1434 "\n" +
   1435 "\n" +
   1436 "  \n" +
   1437 "	\n" +
   1438 " \n" +
   1439 " \n" +
   1440 " \n" +
   1441 "\n" +
   1442 "- \n" +
   1443 "- \n" +
   1444 "\n" +
   1445 "25 , 1821\n" +
   1446 "1828\n" +
   1447 "\n" +
   1448 " - \n" +
   1449 " -  (%)	 \n" +
   1450 "131.940 km (94)\n" +
   1451 "%0.86\n" +
   1452 "\n" +
   1453 " -  2006\n" +
   1454 " -  2001\n" +
   1455 " - 	 \n" +
   1456 "11.120.000 [1] (72)\n" +
   1457 "10.964.020\n" +
   1458 "83.1 ./km (87)\n" +
   1459 "...\n" +
   1460 " - \n" +
   1461 " -  	 2007\n" +
   1462 "$305,595 . (37)\n" +
   1463 "$27,360 (27)\n" +
   1464 "	\n" +
   1465 "()\n" +
   1466 " \n" +
   1467 " -  	(UTC+2)\n" +
   1468 "(UTC+3)\n" +
   1469 "Internet TLD	.gr\n" +
   1470 " 	+30\n" +
   1471 "  (: , :  ),     ,      ,   .   ,           ,           .      ,            .      .                  .\n" +
   1472 "  []\n" +
   1473 "1 \n" +
   1474 "2 \n" +
   1475 "2.1 \n" +
   1476 "2.2 \n" +
   1477 "3 \n" +
   1478 "3.1   \n" +
   1479 "3.2   \n" +
   1480 "3.3   \n" +
   1481 "3.4 \n" +
   1482 "4 \n" +
   1483 "5 \n" +
   1484 "6     \n" +
   1485 "6.1  \n" +
   1486 "7 \n" +
   1487 "7.1 \n" +
   1488 "8 \n" +
   1489 "9  \n" +
   1490 "10  \n" +
   1491 "[]\n" +
   1492 "\n" +
   1493 "\n" +
   1494 " :  \n" +
   1495 "          ,     .     ,        800 ..,      ,     -.             ,           ,           ,              ,                   .\n" +
   1496 "                 146 ..,           .          ,     v   .        .         ,          ,        ,         ,         .   4   15 ,       11     ,       29   1453     .        15 .\n" +
   1497 "      1821       .     1821   1828.  1830       .    1833.   19    20 ,                     ,     ,     ,         1947.\n" +
   1498 "            1949. ,  1952,      .  21   1967  ,      ,     .         ,         .       ,         ,   ,        1974.          8  1974                        11  1975,        1986   2001.         1981         ()     ,  2001.\n" +
   1499 "  \n" +
   1500 " 	(3  ..)\n" +
   1501 " 	(3000-1450 ..)\n" +
   1502 " 	(1600-1100 ..)\n" +
   1503 " 	(1100-800 ..)\n" +
   1504 " 	(800-500 ..)\n" +
   1505 " 	(500 ..- 323 ..)\n" +
   1506 " 	(323-146 ..)\n" +
   1507 " 	(146 ..-330 ..)\n" +
   1508 " 	(330-1453)\n" +
   1509 " 	(1453-1821)\n" +
   1510 " 	(1821  )\n" +
   1511 "\n" +
   1512 "  \n" +
   1513 " \n" +
   1514 " \n" +
   1515 "\n" +
   1516 "[]\n" +
   1517 "\n" +
   1518 "\n" +
   1519 "   1975          ,           2001.        ,    ,   ,      (  ,         )         .             .\n" +
   1520 "    ,     :  ,     .                   ,             .\n" +
   1521 "   , ,      ,              ,          [2] .           ,       2/3,   ,  3/5,  ,     .       ,   ,                  ,          .        , ,  . , ,   ,           (), , ..,   .               ,         .            .\n" +
   1522 "      ,            .        ,     . , ,  1975       ,   , ,        .                 ( ),            ,           .         300    ,       3%    ,     ,   ,   ,    2004  ,           41%.\n" +
   1523 "      ,      ,       .           [3],   ,        ,      ,          .               ,           .       ,       ,           , , ,      ,  , .          ,             .           .  ...         40    .\n" +
   1524 "       ,    , ,  (   ),           .    82  , \"           ,                 \" [3].       :\n" +
   1525 "   ,       .\n" +
   1526 "                  .\n" +
   1527 "        .\n" +
   1528 "     :     ,    ,         .\n" +
   1529 "           ,   ,    .\n" +
   1530 "[]\n" +
   1531 "\n" +
   1532 ":    \n" +
   1533 "      1974 ()                (  ).       ,       ....\n" +
   1534 "[]\n" +
   1535 "\n" +
   1536 ":   \n" +
   1537 "   7  2004,     . ,    .          11 .           .           2008,     16  2007.    16    .                   ,  ,  ..   ...      41.83%  152   300 .     38.10 %  102 .  ..   8.15%  22 .  ..   5.04%  14     ..   3.80%  10 .\n" +
   1538 "[]\n" +
   1539 "\n" +
   1540 "\n" +
   1541 " :   \n" +
   1542 "    13     ,     51 :\n" +
   1543 "\n" +
   1544 "\n" +
   1545 " \n" +
   1546 "\n" +
   1547 "\n" +
   1548 "\n" +
   1549 "\n" +
   1550 "\n" +
   1551 " \n" +
   1552 "\n" +
   1553 "\n" +
   1554 "\n" +
   1555 "\n" +
   1556 "\n" +
   1557 "\n" +
   1558 "\n" +
   1559 "\n" +
   1560 "\n" +
   1561 "\n" +
   1562 "\n" +
   1563 "\n" +
   1564 "   \n" +
   1565 "\n" +
   1566 "\n" +
   1567 "\n" +
   1568 "\n" +
   1569 "\n" +
   1570 "\n" +
   1571 "\n" +
   1572 "\n" +
   1573 "\n" +
   1574 "\n" +
   1575 " \n" +
   1576 "\n" +
   1577 "\n" +
   1578 "\n" +
   1579 "\n" +
   1580 " \n" +
   1581 "\n" +
   1582 "\n" +
   1583 " - \n" +
   1584 "\n" +
   1585 "\n" +
   1586 "\n" +
   1587 "\n" +
   1588 "\n" +
   1589 "\n" +
   1590 " \n" +
   1591 "\n" +
   1592 "\n" +
   1593 "\n" +
   1594 "\n" +
   1595 "\n" +
   1596 "\n" +
   1597 "\n" +
   1598 " \n" +
   1599 "\n" +
   1600 "\n" +
   1601 "\n" +
   1602 " \n" +
   1603 "\n" +
   1604 "\n" +
   1605 "\n" +
   1606 "\n" +
   1607 ",      ,   ,      .     147 ,    900   133 .   1999,  5.775   : 361   5.560 ,   12.817 \n" +
   1608 "\n" +
   1609 "\n" +
   1610 "\n" +
   1611 "\n" +
   1612 "\n" +
   1613 "....\n" +
   1614 "\n" +
   1615 "\n" +
   1616 "'\n" +
   1617 "\n" +
   1618 "\n" +
   1619 "\n" +
   1620 "EA\n" +
   1621 "AHNA\n" +
   1622 "\n" +
   1623 "\n" +
   1624 "\n" +
   1625 "\n" +
   1626 "\n" +
   1627 "\n" +
   1628 "\n" +
   1629 "\n" +
   1630 "\n" +
   1631 "\n" +
   1632 "\n" +
   1633 "\n" +
   1634 "\n" +
   1635 "\n" +
   1636 "        \n" +
   1637 "\n" +
   1638 "\n" +
   1639 "\n" +
   1640 " \n" +
   1641 "\n" +
   1642 " (2917m)\n" +
   1643 "\n" +
   1644 "\n" +
   1645 "\n" +
   1646 "\n" +
   1647 "\n" +
   1648 "\n" +
   1649 "\n" +
   1650 "\n" +
   1651 "\n" +
   1652 "\n" +
   1653 "\n" +
   1654 "\n" +
   1655 "\n" +
   1656 "\n" +
   1657 "\n" +
   1658 "\n" +
   1659 "\n" +
   1660 "\n" +
   1661 "\n" +
   1662 " \n" +
   1663 "\n" +
   1664 "\n" +
   1665 "\n" +
   1666 "\n" +
   1667 "\n" +
   1668 "[]\n" +
   1669 "  \n" +
   1670 " :    \n" +
   1671 "  80%        .       ,  28%    .\n" +
   1672 " 2917 . ,   (, )\n" +
   1673 " 2637 .   ()\n" +
   1674 " 2524 .   (, , ....)\n" +
   1675 " 2520 .   (, , )\n" +
   1676 " 2510 .  ()\n" +
   1677 " 2497 .   ()\n" +
   1678 " 2495 .  ()\n" +
   1679 "  2469 .   ()\n" +
   1680 " 2457 .  (, )\n" +
   1681 " 2456 .  ()\n" +
   1682 "\n" +
   1683 "\n" +
   1684 "\n" +
   1685 "\n" +
   1686 "       ,     ,      ,     ,      .              .     ,    ,  ,         . 180       ,      .      15.021 ,    ,       ,       ,      1500.       1.181 .\n" +
   1687 "\n" +
   1688 "\n" +
   1689 "   \n" +
   1690 " :   \n" +
   1691 "[]\n" +
   1692 "  \n" +
   1693 " :    \n" +
   1694 "    ,         .       :\n" +
   1695 " 96.513 ..\n" +
   1696 " 75.600 .\n" +
   1697 "  72.488 .\n" +
   1698 "  45.625 .\n" +
   1699 "  42.823 .\n" +
   1700 "  ( ) 43.122 .\n" +
   1701 "  ( ) 38.325 .\n" +
   1702 " 37.688 .\n" +
   1703 "          ,     (68.531 .)     (56.793 .).\n" +
   1704 "\n" +
   1705 "[]\n" +
   1706 "  \n" +
   1707 "    ,       .    ,             ,       .      ,        ,            .         ,                 .\n" +
   1708 "        .           .\n" +
   1709 " 297 .\n" +
   1710 " 220 .\n" +
   1711 " () 205 .\n" +
   1712 " [4] 204 .\n" +
   1713 " [4] 130 .\n" +
   1714 " [4] 118 .\n" +
   1715 " () 115 .\n" +
   1716 " 110 .\n" +
   1717 " 110 .\n" +
   1718 "[]\n" +
   1719 "\n" +
   1720 "                  .           :\n" +
   1721 "-   ( ,  ,     ) -   (,  , ,  , ,    ) -  ( ,    ,  ) -  (     >1500   , >1800     >2000  ).\n" +
   1722 "       .               -    .           (  ,        ),             .  , ,       .      ,           .        0,0    .               . , ,    3 .\n" +
   1723 "      34  42o           .            ,        .             (           )     .                    .               ,           .\n" +
   1724 "           :                                .\n" +
   1725 "            ,           5-10 C   ,  0-5 C              .\n" +
   1726 "                       ,       .                 ,       .\n" +
   1727 "             ,      .          ,    ,                  .\n" +
   1728 "                     29 C  35 C.                        ()     .\n" +
   1729 "    ,      ,     .                  .\n" +
   1730 "[]\n" +
   1731 "\n" +
   1732 "\n" +
   1733 " :   \n" +
   1734 "     ,           ....       ,         ...,     .  2004          12 .       .\n" +
   1735 "      ,       ,          ,  1  2001.                    ,     3,3%  ...        ..    .                                 1                  ...     75%    .     2003    1     : ,  ,  ,  ,      .\n" +
   1736 "  ,                  ,     ,    ,      .     3,9%   2004.\n" +
   1737 "             (),              (...),          2001.\n" +
   1738 "[]\n" +
   1739 "\n" +
   1740 "\n" +
   1741 " :   \n" +
   1742 "   :  2001\n" +
   1743 "     (2001)[5]       10.934.097 .    ,      ( ) 10.964.020 .\n" +
   1744 "                ,   2005:  97%   ,   ,  o.   500.000-800.000       - ,             .          .      ,         .          98.000 , ,         140.000 .             .        30.000     50.000      .     50.000.  ,   ,  30.000,              () 300.      500   .         5.000 ,    2.000     .  250         ,         .         2.000 .     , ,           .            .          .        [5],      .          ,     ,  ,    .       ,             200.000-300.000. [6]\n" +
   1745 "          .         10%      950.000 .                             .          2001       , , , , , , .\n" +
   1746 "                   ....    .        ,     .\n" +
   1747 "[]\n" +
   1748 "    \n" +
   1749 "\n" +
   1750 "  :\n" +
   1751 " \n" +
   1752 "  \n" +
   1753 "  \n" +
   1754 " :\n" +
   1755 " \n" +
   1756 " \n" +
   1757 " \n" +
   1758 "[]\n" +
   1759 " \n" +
   1760 " :    \n" +
   1761 "  2004,       12 ,       18 . ,        ,       .           6   2008        .         ,   .             ,     2             ,       .\n" +
   1762 "           ,               . , ,           , '       ,      .       (9      , , , 11     , ,     , ,   600        ).    5       .           ,           ,                    .\n" +
   1763 "[]\n" +
   1764 "\n" +
   1765 "\n" +
   1766 "  \n" +
   1767 " \n" +
   1768 "  \n" +
   1769 " \n" +
   1770 " \n" +
   1771 " \n" +
   1772 " \n" +
   1773 " \n" +
   1774 " \n" +
   1775 "[]\n" +
   1776 "\n" +
   1777 "		\n" +
   1778 "1 		 \n" +
   1779 "6 		 \n" +
   1780 "	 	   \n" +
   1781 "25 	     	      1821\n" +
   1782 "	 	 \n" +
   1783 "		  \n" +
   1784 "	  (  )	   \n" +
   1785 "1 		 \n" +
   1786 "	 	 \n" +
   1787 "15 	  	 \n" +
   1788 "28 	  	  (1940)\n" +
   1789 "25 		 \n" +
   1790 "26 	 	 \n" +
   1791 "[]\n" +
   1792 "\n" +
   1793 "\n" +
   1794 " www.destatis.de   , 2006\n" +
   1795 "   ,  30\n" +
   1796 " 3,0 3,1   ,  82\n" +
   1797 " 4,0 4,1 4,2   \n" +
   1798 " 5,0 5,1  2001\n" +
   1799 " :      2005     ,    ...\n" +
   1800 "[]\n" +
   1801 " \n" +
   1802 "\n" +
   1803 "  \n" +
   1804 "   \n" +
   1805 "  \n" +
   1806 "     \n" +
   1807 "  :        (Commons).\n" +
   1808 "   \n" +
   1809 "[]\n" +
   1810 " \n" +
   1811 "\n" +
   1812 "   ( )\n" +
   1813 "  \n" +
   1814 "   (      )\n" +
   1815 "   ( )\n" +
   1816 "  \n" +
   1817 " \n";
   1818 
   1819 
   1820 var hebrew =
   1821 "  \n" +
   1822 " ,  \n" +
   1823 " : , \n" +
   1824 "\n" +
   1825 "             .         \"\",       .\n" +
   1826 "\n" +
   1827 "     \n" +
   1828 "\n" +
   1829 "        ,      .      ,    \n" +
   1830 "\n" +
   1831 "       ,        3,500      5,000     .                  .   ,       ( -1 \"),        ( -2 \")      .  ,                        .                            .\n" +
   1832 "  \n" +
   1833 "\n" +
   1834 "    *  \n" +
   1835 "\n" +
   1836 "       \n" +
   1837 "     \n" +
   1838 "     \n" +
   1839 "     '\n" +
   1840 "      \n" +
   1841 "      \n" +
   1842 "\n" +
   1843 "    *  \n" +
   1844 "\n" +
   1845 "     '\n" +
   1846 "      \n" +
   1847 "     \n" +
   1848 "      \n" +
   1849 "     \n" +
   1850 "     '\n" +
   1851 "      \n" +
   1852 "     \n" +
   1853 "     \n" +
   1854 "     \n" +
   1855 "     '\n" +
   1856 "     \n" +
   1857 "     '\n" +
   1858 "\n" +
   1859 "    *  \n" +
   1860 "\n" +
   1861 "      \n" +
   1862 "     \n" +
   1863 "      \n" +
   1864 "     -\n" +
   1865 "     - \n" +
   1866 "      \n" +
   1867 "     \n" +
   1868 "\n" +
   1869 "    *  \n" +
   1870 "\n" +
   1871 "     \n" +
   1872 "         \n" +
   1873 "     \n" +
   1874 "     \n" +
   1875 "     - \n" +
   1876 "      \n" +
   1877 "\n" +
   1878 "    *  \n" +
   1879 "\n" +
   1880 "        \n" +
   1881 "      \n" +
   1882 "      \n" +
   1883 "     -\n" +
   1884 "     -\n" +
   1885 "      \n" +
   1886 "     \n" +
   1887 "\n" +
   1888 " \n" +
   1889 "\n" +
   1890 "    *  \n" +
   1891 "    *      \n" +
   1892 "\n" +
   1893 " \n" +
   1894 " \n" +
   1895 "\n" +
   1896 "\n" +
   1897 " \n" +
   1898 "[]\n" +
   1899 "\n" +
   1900 "    * 1 -\n" +
   1901 "          o 1.1    \n" +
   1902 "    * 2  \n" +
   1903 "          o 2.1  \n" +
   1904 "          o 2.2  \n" +
   1905 "          o 2.3  '\n" +
   1906 "          o 2.4   \n" +
   1907 "          o 2.5   \n" +
   1908 "    * 3  ':   \n" +
   1909 "    * 4  :   \n" +
   1910 "    * 5 ',      :    \n" +
   1911 "    * 6  :  \n" +
   1912 "    * 7    ,  '\n" +
   1913 "    * 8 \n" +
   1914 "    * 9     \n" +
   1915 "    * 10  :  \n" +
   1916 "    * 11  '\n" +
   1917 "    * 12  \n" +
   1918 "    * 13    \n" +
   1919 "    * 14  \n" +
   1920 "    * 15  \n" +
   1921 "    * 16  \n" +
   1922 "    * 17  \n" +
   1923 "\n" +
   1924 "[] -\n" +
   1925 "\n" +
   1926 "            .         '     1.36  .               ,   1.27  .           ,           65,000 .\n" +
   1927 "\n" +
   1928 "            6,000 \".     ,     ,             ,     ,    .\n" +
   1929 "\n" +
   1930 "            ,      .         - .\n" +
   1931 "\n" +
   1932 "[]    \n" +
   1933 "\n" +
   1934 "          \n" +
   1935 "\n" +
   1936 "  ,  ,      - '   \",   ,    \"           - 2800 \".     .           .  ,      .\n" +
   1937 "\n" +
   1938 "- '          ,        '.    ,      .  ,   ,       .\n" +
   1939 "\n" +
   1940 "[]  \n" +
   1941 "\n" +
   1942 "[]  \n" +
   1943 "\n" +
   1944 "        \n" +
   1945 "\n" +
   1946 "  (: , : Xi),     .       ,          . - '         4,200 ,      . 17  -14   ,    '     '  ,  - - '     '.\n" +
   1947 "\n" +
   1948 "  '      ,    .      ,  431  471      .\n" +
   1949 "\n" +
   1950 "           [1].        2000 \" .     -          [2].               ',       .\n" +
   1951 "\n" +
   1952 "[]  \n" +
   1953 "\n" +
   1954 "        \n" +
   1955 "\n" +
   1956 "            .  ,   ,   -13 \" ,    (: , : Shng).  ,       1600-1046 \" ,   .  ,  -1300 ,     .  ,   (),      ,    .          .   31 ,     .\n" +
   1957 "\n" +
   1958 "          ,      -1350 \"       .      -      ,        .         ,   ' (   ),      .           ,              .  ,          ,     .         .            ,         ,      .\n" +
   1959 "\n" +
   1960 "[]  '\n" +
   1961 "\n" +
   1962 "        '\n" +
   1963 "\n" +
   1964 " ' (: , : Zhu),        , -1122 \"  256 \" - 866 .           .     . '   ,       \" \".  '  ,     ',             .     '  ,     ,         ,          ,    ,    .        ,     ,   ,         .         .\n" +
   1965 "\n" +
   1966 "[]   \n" +
   1967 "\n" +
   1968 "         \n" +
   1969 "\n" +
   1970 "   (: )       722 \"  481 \".         ,         .\n" +
   1971 "\n" +
   1972 "                   .      ,     .                      .         .         .\n" +
   1973 "\n" +
   1974 "[]   \n" +
   1975 "\n" +
   1976 "         \n" +
   1977 "\n" +
   1978 "   (: , : Zhn Gu)    \"   221 \"       '. ,   ,     ,   ,       ' ,      ,     ,    35      .     \"  \",    ,    .\n" +
   1979 "\n" +
   1980 "  ,     ,          ,        .   \"        :  ' (), ' (),  (),  (), ' (),  () ' ().            ( -   ),     ',  () - ,     '.\n" +
   1981 "\n" +
   1982 "                  .      ,          ,       .            , , ,      .\n" +
   1983 "\n" +
   1984 " ,   '      ,   '     .\n" +
   1985 "\n" +
   1986 "[]  ':   \n" +
   1987 "\n" +
   1988 "        '\n" +
   1989 "\n" +
   1990 "    212 \"  ' -,   '.        ,         .  212 \"    '           .\n" +
   1991 "\n" +
   1992 "     '   12 ,                           ,   .  '          (    ).       ,         .\n" +
   1993 "\n" +
   1994 "        (China),     ' (),    .\n" +
   1995 "\n" +
   1996 "[]  :   \n" +
   1997 "\n" +
   1998 "        \n" +
   1999 "\n" +
   2000 "     202 \".                      -20.          ,  .         \"-\" (    )     ,          .           :  .\n" +
   2001 "\n" +
   2002 ",       ,      ,     .        ,         .        .         ,     ,    .         .    ,  ,           -,  ,        :   .           .    ,           .      184,                  .      .\n" +
   2003 "\n" +
   2004 "[] ',      :    \n" +
   2005 "\n" +
   2006 "        '\n" +
   2007 "\n" +
   2008 "    280     '.       .   -4    (      )    ,            .  303          ' '. -,       ,   ,            '.  -         .         ',         .         ,    ,          .\n" +
   2009 "\n" +
   2010 "     ,    ,   ',       .           , ,  '.      ',  '  .                    .    ,     589   300  .\n" +
   2011 "\n" +
   2012 "[]  :  \n" +
   2013 "\n" +
   2014 "        \n" +
   2015 "\n" +
   2016 " 618   ,         .         . ,      -1,          . '- (  ),         .            . ,   ,             .      :     .\n" +
   2017 "\n" +
   2018 "[]    ,  '\n" +
   2019 "\n" +
   2020 "        \n" +
   2021 "\n" +
   2022 " 960            .   ,   ,     .          . '         1115   '  ' '' (''    ')  10      .  '      ,    ,          '.        '     '   .           ( ,  '        ).      ,            .\n" +
   2023 "\n" +
   2024 "[] \n" +
   2025 "\n" +
   2026 " '         ,                    .           (   ),   \" \" (Pax Mongolica).     ,   ,       . ,                  .  ,    ,      (: \" \")             ' ('     '       ).\n" +
   2027 "\n" +
   2028 "[]     \n" +
   2029 "\n" +
   2030 "  ,      \"\" ,                .          1368.        : ,   ,      ,      ,         ' .        1,500            .  100,000        .            .\n" +
   2031 "\n" +
   2032 " -,  ,               ,      .               ,    .  ,      .         ,                  .\n" +
   2033 "\n" +
   2034 "  ,                     .\n" +
   2035 "\n" +
   2036 "     -40% -60  .      .            .   ,                    .\n" +
   2037 "\n" +
   2038 "[]  :  \n" +
   2039 "\n" +
   2040 "        \n" +
   2041 "\n" +
   2042 "     ,    ,         .    ,   ,               .              .       .\n" +
   2043 "\n" +
   2044 "                ' ,     ,        1405 1433           .    ,  62   28,000          .\n" +
   2045 "\n" +
   2046 ",     -15,                   .                 .       -17.\n" +
   2047 "\n" +
   2048 "[]  '\n" +
   2049 "\n" +
   2050 "        '\n" +
   2051 "\n" +
   2052 "   ,  1644  '   ,          '  '.     '               ,  .     '               .\n" +
   2053 "\n" +
   2054 "       '        .       '      .                            .  '                .       '  ,  1700  100  ,   220   1800.\n" +
   2055 "\n" +
   2056 "\n" +
   2057 "   ,      , , ,  \n" +
   2058 "   ,      , , ,  \n" +
   2059 "\n" +
   2060 "  -19,     '     .    ,             .        ,      ,        1840. ,  ,            .             1842   '.     (1864-1851)   (1868-1853),                    .\n" +
   2061 "\n" +
   2062 "                  .\n" +
   2063 "\n" +
   2064 "       -19,   '           . ,   ,     ,        ,        .  ,   ,         .           ,             .    \"  \"      - (1885-1883)   -  (1895-1894)\n" +
   2065 "\n" +
   2066 "    -20,     ,         .      ,        .           (     )        .\n" +
   2067 "\n" +
   2068 "[]  \n" +
   2069 "\n" +
   2070 "          \n" +
   2071 "\n" +
   2072 "    ,    ,   ,      -        '     .  ',   ,  10  1911.    , 12  1912       '    -  .               \" \"      ',          -.    ,                 1915.                     ,        1916    .          ,        '.\n" +
   2073 "\n" +
   2074 "   (   )  1919         -20,      . ,                          ,      .\n" +
   2075 "\n" +
   2076 "1920,   -     ,       .   ,       ,         .     1925   '      ()              .        ,  '    ,      .    1927    . 1934     (    -)  ,                     .\n" +
   2077 "\n" +
   2078 "  ,       .               -  (1945-1931)           1937    .          -1945, -1949      .\n" +
   2079 "\n" +
   2080 "[]    \n" +
   2081 "\n" +
   2082 "            \n" +
   2083 "\n" +
   2084 "   .      .    .\n" +
   2085 "\n" +
   2086 "'                           .       ( 2004)               .\n" +
   2087 "\n" +
   2088 "         1  1949,                 ,                 .         -20,              .\n" +
   2089 "\n" +
   2090 "[]  \n" +
   2091 "\n" +
   2092 "    *                .\n" +
   2093 "\n" +
   2094 "[]  \n" +
   2095 "\n" +
   2096 "    *  ' ' ,    ,  , 2005.\n" +
   2097 "\n" +
   2098 "[]  \n" +
   2099 "\n" +
   2100 "    *  -,  ,  ,  \" \"\n" +
   2101 "\n" +
   2102 "\n" +
   2103 "[]  \n" +
   2104 "\n" +
   2105 "   1. ^         -\n" +
   2106 "   2. ^      (  )\n";
   2107 
   2108 
   2109 var japanese =
   2110 "\n" +
   2111 ": Wikipedia\n" +
   2112 ": , \n" +
   2113 "\n" +
   2114 "\n" +
   2115 "\n" +
   2116 "\n" +
   2117 "\n" +
   2118 "\n" +
   2119 "\n" +
   2120 " 	\n" +
   2121 " 	\n" +
   2122 "\n" +
   2123 "\n" +
   2124 " 	\n" +
   2125 "\n" +
   2126 "\n" +
   2127 " 	 	 	\n" +
   2128 " 	\n" +
   2129 " 	\n" +
   2130 " 	 	\n" +
   2131 "\n" +
   2132 " 	 	\n" +
   2133 " 	 	\n" +
   2134 "\n" +
   2135 "\n" +
   2136 "\n" +
   2137 " 	 	 	\n" +
   2138 " 	\n" +
   2139 "\n" +
   2140 " 	\n" +
   2141 " 	 	\n" +
   2142 "\n" +
   2143 "\n" +
   2144 " 	(:\n" +
   2145 ")\n" +
   2146 "\n" +
   2147 "\n" +
   2148 "\n" +
   2149 "\n" +
   2150 "\n" +
   2151 "[]\n" +
   2152 "\n" +
   2153 "    * 1 \n" +
   2154 "    * 2 \n" +
   2155 "          o 2.1 \n" +
   2156 "          o 2.2 \n" +
   2157 "                + 2.2.1 \n" +
   2158 "                + 2.2.2 \n" +
   2159 "                + 2.2.3 \n" +
   2160 "          o 2.3 \n" +
   2161 "                + 2.3.1 \n" +
   2162 "                + 2.3.2 \n" +
   2163 "          o 2.4 \n" +
   2164 "          o 2.5 \n" +
   2165 "          o 2.6 \n" +
   2166 "          o 2.7 \n" +
   2167 "          o 2.8 \n" +
   2168 "          o 2.9 \n" +
   2169 "          o 2.10 \n" +
   2170 "          o 2.11 \n" +
   2171 "                + 2.11.1 \n" +
   2172 "                + 2.11.2 19131916\n" +
   2173 "                + 2.11.3 19161920\n" +
   2174 "                + 2.11.4 19201928\n" +
   2175 "                + 2.11.5 19281931\n" +
   2176 "                + 2.11.6 19311937\n" +
   2177 "                + 2.11.7 19371945\n" +
   2178 "                + 2.11.8 \n" +
   2179 "                      # 2.11.8.1 \n" +
   2180 "                      # 2.11.8.2 \n" +
   2181 "          o 2.12 \n" +
   2182 "                + 2.12.1 19491957\n" +
   2183 "                + 2.12.2 19581965\n" +
   2184 "                + 2.12.3 19661969\n" +
   2185 "                + 2.12.4 19691976\n" +
   2186 "                + 2.12.5 1976\n" +
   2187 "                      # 2.12.5.1 \n" +
   2188 "                      # 2.12.5.2 \n" +
   2189 "    * 3 \n" +
   2190 "    * 4 \n" +
   2191 "          o 4.1 1600221\n" +
   2192 "          o 4.2 221249\n" +
   2193 "          o 4.3 249583\n" +
   2194 "          o 4.4 5831276\n" +
   2195 "    * 5 \n" +
   2196 "    * 6 \n" +
   2197 "          o 6.1 \n" +
   2198 "          o 6.2 \n" +
   2199 "          o 6.3 \n" +
   2200 "    * 7 \n" +
   2201 "    * 8 \n" +
   2202 "\n" +
   2203 "[] \n" +
   2204 "\n" +
   2205 "\n" +
   2206 "\n" +
   2207 "    * \n" +
   2208 "    * \n" +
   2209 "    * 2070 - 1600\n" +
   2210 "    * 1600 - 1211\n" +
   2211 "\n" +
   2212 "    * 1211 - 256\n" +
   2213 "          o 770 - 403453403\n" +
   2214 "          o 403 - 221\n" +
   2215 "    * 221 - 2076\n" +
   2216 "    * \n" +
   2217 "          o 206 - 8\n" +
   2218 "          o 8 - 23\n" +
   2219 "          o 25 - 220\n" +
   2220 "    * 220 - 280\n" +
   2221 "          o \n" +
   2222 "    * 265 - 420\n" +
   2223 "          o 265 - 316\n" +
   2224 "          o 317 - 420()\n" +
   2225 "          o 304 - 439\n" +
   2226 "    * 439 - 589\n" +
   2227 "          o \n" +
   2228 "          o \n" +
   2229 "    * 581 - 619\n" +
   2230 "    * 618 - 907\n" +
   2231 "          o \n" +
   2232 "    * \n" +
   2233 "          o \n" +
   2234 "          o \n" +
   2235 "    * \n" +
   2236 "          o 960 - 1127\n" +
   2237 "          o 1127 - 1279\n" +
   2238 "          o \n" +
   2239 "    * 1271 - 1368\n" +
   2240 "    * 1368 - 1644\n" +
   2241 "          o \n" +
   2242 "    * 1616 - 19121616 - 1636\n" +
   2243 "          o \n" +
   2244 "    * 1912 - \n" +
   2245 "    * 1949 - \n" +
   2246 "\n" +
   2247 "[] \n" +
   2248 "\n" +
   2249 "[] \n" +
   2250 "\n" +
   2251 "\n" +
   2252 "\n" +
   2253 "[] \n" +
   2254 "\n" +
   2255 "2\n" +
   2256 "\n" +
   2257 "[] \n" +
   2258 "1976\n" +
   2259 "1976\n" +
   2260 "\n" +
   2261 "\n" +
   2262 "\n" +
   2263 "    * 7000?~5000?()\n" +
   2264 "    * 6000?~5000?()\n" +
   2265 "    * 6000?~5000?()\n" +
   2266 "    * 6000?~5000?()\n" +
   2267 "    * 4800?~2500?\n" +
   2268 "    * 5000?~4000?\n" +
   2269 "    * 4300?~2400?()()\n" +
   2270 "    * 2500?~2000?\n" +
   2271 "    * 2000?~1600?\n" +
   2272 "\n" +
   2273 "[] \n" +
   2274 "\n" +
   2275 "\n" +
   2276 "\n" +
   2277 "[1]\n" +
   2278 "\n" +
   2279 "    * ()1400012000\n" +
   2280 "    * ()12000\n" +
   2281 "    * ()70005000\n" +
   2282 "    * ()45003300\n" +
   2283 "    * 30002500\n" +
   2284 "    * 25001.3Km1.1Km\n" +
   2285 "    *  50004000\n" +
   2286 "    *  ()526042001977\n" +
   2287 "    *  2600850\n" +
   2288 "\n" +
   2289 "[] \n" +
   2290 "\n" +
   2291 "    * ()5200?\n" +
   2292 "\n" +
   2293 "[] \n" +
   2294 "\n" +
   2295 "[] \n" +
   2296 "\n" +
   2297 "[2]\n" +
   2298 "\n" +
   2299 "[3][4]\n" +
   2300 "\n" +
   2301 "11770759403\n" +
   2302 "\n" +
   2303 "[] \n" +
   2304 "\n" +
   2305 "\n" +
   2306 "\n" +
   2307 "\n" +
   2308 "\n" +
   2309 "530\n" +
   2310 "\n" +
   2311 "\n" +
   2312 "\n" +
   2313 "[] \n" +
   2314 "\n" +
   2315 "\n" +
   2316 "6221\n" +
   2317 "\n" +
   2318 "\n" +
   2319 "210206\n" +
   2320 "\n" +
   2321 "\n" +
   2322 "\n" +
   2323 "202154141\n" +
   2324 "\n" +
   2325 "8\n" +
   2326 "\n" +
   2327 "[] \n" +
   2328 "\n" +
   2329 "\n" +
   2330 "\n" +
   2331 "184589\n" +
   2332 "\n" +
   2333 "208220221229\n" +
   2334 "\n" +
   2335 "[5]\n" +
   2336 "\n" +
   2337 "26326528030031612\n" +
   2338 "\n" +
   2339 "4\n" +
   2340 "\n" +
   2341 "439471577581589\n" +
   2342 "\n" +
   2343 "\n" +
   2344 "\n" +
   2345 "[] \n" +
   2346 "\n" +
   2347 "\n" +
   2348 "\n" +
   2349 "618\n" +
   2350 "\n" +
   2351 "626\n" +
   2352 "\n" +
   2353 "\n" +
   2354 "\n" +
   2355 "690\n" +
   2356 "\n" +
   2357 "7127638758849071\n" +
   2358 "\n" +
   2359 "[] \n" +
   2360 ":Compass in a wooden frame.jpg\n" +
   2361 "\n" +
   2362 "\n" +
   2363 "960976\n" +
   2364 "\n" +
   2365 "\n" +
   2366 "\n" +
   2367 "\n" +
   2368 "\n" +
   2369 "\n" +
   2370 "\n" +
   2371 "1127\n" +
   2372 "\n" +
   2373 "\n" +
   2374 "\n" +
   2375 "[] \n" +
   2376 "\n" +
   2377 "1312341279\n" +
   2378 "\n" +
   2379 "51271\n" +
   2380 "\n" +
   2381 "\n" +
   2382 "\n" +
   2383 "()\n" +
   2384 "\n" +
   2385 "1279\n" +
   2386 "\n" +
   2387 "\n" +
   2388 "\n" +
   2389 "135113681388\n" +
   2390 "\n" +
   2391 "[] \n" +
   2392 "\n" +
   2393 "\n" +
   2394 "\n" +
   2395 "170m50m70510\n" +
   2396 "\n" +
   2397 "\n" +
   2398 "\n" +
   2399 "1449\n" +
   2400 "\n" +
   2401 "\n" +
   2402 "\n" +
   2403 "1644\n" +
   2404 "\n" +
   2405 "17163617183\n" +
   2406 "\n" +
   2407 "\n" +
   2408 "\n" +
   2409 "\n" +
   2410 "\n" +
   2411 "[] \n" +
   2412 "\n" +
   2413 "\n" +
   2414 "\n" +
   2415 "1818391840\n" +
   2416 "\n" +
   2417 "1861 - 1875\n" +
   2418 "\n" +
   2419 "18941895\n" +
   2420 "\n" +
   2421 "1911191211212\n" +
   2422 "\n" +
   2423 "[] \n" +
   2424 "\n" +
   2425 "[] \n" +
   2426 "\n" +
   2427 "\n" +
   2428 "\n" +
   2429 "[] 19131916\n" +
   2430 "\n" +
   2431 "\n" +
   2432 "\n" +
   2433 "191310111914151\n" +
   2434 "\n" +
   2435 "\n" +
   2436 "\n" +
   2437 "191559211916\n" +
   2438 "\n" +
   2439 "[] 19161920\n" +
   2440 "\n" +
   2441 "[6]191781419185[7]191954192219207\n" +
   2442 "\n" +
   2443 "[] 19201928\n" +
   2444 "\n" +
   2445 "\n" +
   2446 "\n" +
   2447 "191471919192119181924192571924619254192619271412418391928612\n" +
   2448 "\n" +
   2449 "[] 19281931\n" +
   2450 "\n" +
   2451 "\n" +
   2452 "\n" +
   2453 "504193019301931\n" +
   2454 "\n" +
   2455 "[8]\n" +
   2456 "\n" +
   2457 "[] 19311937\n" +
   2458 "\n" +
   2459 "\n" +
   2460 "\n" +
   2461 "19319\n" +
   2462 "\n" +
   2463 "193210193351934\n" +
   2464 "\n" +
   2465 "19311934\n" +
   2466 "\n" +
   2467 "[] 19371945\n" +
   2468 "\n" +
   2469 "1937\n" +
   2470 "D\n" +
   2471 "D\n" +
   2472 "\n" +
   2473 "194112\n" +
   2474 "\n" +
   2475 "194581\n" +
   2476 "\n" +
   2477 "1949101\n" +
   2478 "\n" +
   2479 "[] \n" +
   2480 "\n" +
   2481 "[] \n" +
   2482 "\n" +
   2483 "\n" +
   2484 "\n" +
   2485 "\n" +
   2486 "\n" +
   2487 "\n" +
   2488 "\n" +
   2489 "191313 \n" +
   2490 "\n" +
   2491 "1925193313141936[9]\n" +
   2492 "\n" +
   2493 "19471950\n" +
   2494 "\n" +
   2495 "[] \n" +
   2496 "\n" +
   2497 ")193193119336\n" +
   2498 "\n" +
   2499 "[] \n" +
   2500 "\n" +
   2501 "[] 19491957\n" +
   2502 "\n" +
   2503 "\n" +
   2504 "\n" +
   2505 "19501953\n" +
   2506 "\n" +
   2507 "19562\n" +
   2508 "\n" +
   2509 "[] 19581965\n" +
   2510 "\n" +
   2511 "19583\n" +
   2512 "\n" +
   2513 "195961960GNP1%\n" +
   2514 "\n" +
   2515 "19591960150020005000196025\n" +
   2516 "\n" +
   2517 "19633119641965\n" +
   2518 "\n" +
   2519 "\n" +
   2520 "\n" +
   2521 "[] 19661969\n" +
   2522 "\n" +
   2523 "\n" +
   2524 "\n" +
   2525 "1966\n" +
   2526 "\n" +
   2527 "\n" +
   2528 "\n" +
   2529 "19661967\n" +
   2530 "\n" +
   2531 "1969\n" +
   2532 "\n" +
   2533 "[] 19691976\n" +
   2534 "\n" +
   2535 "1976 \n" +
   2536 "\n" +
   2537 "\n" +
   2538 "\n" +
   2539 "[] 1976\n" +
   2540 "\n" +
   2541 "\n" +
   2542 "\n" +
   2543 "19781211\n" +
   2544 "\n" +
   2545 "[] \n" +
   2546 "\n" +
   2547 "\n" +
   2548 "\n" +
   2549 "19891980\n" +
   2550 "\n" +
   2551 "2003SARS\n" +
   2552 "\n" +
   2553 "199019971999\n" +
   2554 "\n" +
   2555 "2050\n" +
   2556 "\n" +
   2557 "\n" +
   2558 "\n" +
   2559 "[] \n" +
   2560 "\n" +
   2561 "\n" +
   2562 "\n" +
   2563 "1997\n" +
   2564 "\n" +
   2565 "\n" +
   2566 "\n" +
   2567 "[] \n" +
   2568 "\n" +
   2569 "1980\n" +
   2570 " 	 	 	 	\n" +
   2571 " 	2205 		13,553,923 	\n" +
   2572 " 			20,000,000? 	\n" +
   2573 " 	22 	12,233,062 	59,594,978 	\n" +
   2574 " 			20,000,000? 	\n" +
   2575 " 	144 	9,946,919 	49,730,550 	\n" +
   2576 " 	280 	2,459,804 	16,163,863 	\n" +
   2577 " 	2606 	8,907,536 	46,019,056 	\n" +
   2578 " 	14755 	8,914,709 	52,919,309 	\n" +
   2579 " 	31080 	14,852,684 	33,303,889 	\n" +
   2580 " 	61195 	7,223,400 	48,490,400 	\n" +
   2581 " 	271290 	13,196,206 	58,834,711 	\n" +
   2582 " 	61570 	10,621,436 	60,692,850 	\n" +
   2583 " 	1644 		45,000,000 	\n" +
   2584 "501711 		100,000,000 	\n" +
   2585 "271762 		200,000,000 	\n" +
   2586 "551790 		300,000,000 	\n" +
   2587 "171812 		333,700,560 	\n" +
   2588 "141834 		400,000,000 	\n" +
   2589 " 	361947 		455,590,000 	\n" +
   2590 " 	1995 		1,211,210,000 	\n" +
   2591 "\n" +
   2592 "[] \n" +
   2593 "\n" +
   2594 "[] 1600221\n" +
   2595 "\n" +
   2596 "[10]\n" +
   2597 "\n" +
   2598 "[] 221249\n" +
   2599 "\n" +
   2600 "\n" +
   2601 "\n" +
   2602 "13[11][12]249[13]\n" +
   2603 "\n" +
   2604 "[] 249583\n" +
   2605 "\n" +
   2606 "5,6030022,3\n" +
   2607 "\n" +
   2608 "[] 5831276\n" +
   2609 "\n" +
   2610 "583[14]595[15]10\n" +
   2611 "\n" +
   2612 "[] \n" +
   2613 "\n" +
   2614 "\n" +
   2615 "\n" +
   2616 "[] \n" +
   2617 "\n" +
   2618 "\n" +
   2619 "\n" +
   2620 "[] \n" +
   2621 "\n" +
   2622 "\n" +
   2623 "\n" +
   2624 "[] \n" +
   2625 "\n" +
   2626 "[16] \n" +
   2627 "\n" +
   2628 "[] \n" +
   2629 "\n" +
   2630 "\n" +
   2631 "\n" +
   2632 "[17]\n" +
   2633 "\n" +
   2634 "[] \n" +
   2635 "\n" +
   2636 "    * \n" +
   2637 "    * \n" +
   2638 "    * \n" +
   2639 "    * \n" +
   2640 "    * \n" +
   2641 "          o \n" +
   2642 "          o \n" +
   2643 "    * \n" +
   2644 "    * \n" +
   2645 "    * \n" +
   2646 "    * \n" +
   2647 "    * \n" +
   2648 "    * \n" +
   2649 "    * \n" +
   2650 "    * \n" +
   2651 "    * \n" +
   2652 "    * \n" +
   2653 "\n" +
   2654 "Wikibooks\n" +
   2655 "\n" +
   2656 "[] \n" +
   2657 "\n" +
   2658 "   1. ^ \n" +
   2659 "   2. ^ \n" +
   2660 "   3. ^ \n" +
   2661 "   4. ^ \n" +
   2662 "   5. ^ \n" +
   2663 "   6. ^ 19168\n" +
   2664 "   7. ^ \n" +
   2665 "   8. ^ 192830\n" +
   2666 "   9. ^ \n" +
   2667 "  10. ^ \n" +
   2668 "  11. ^ 9\n" +
   2669 "  12. ^ \n" +
   2670 "  13. ^ \n" +
   2671 "  14. ^ \n" +
   2672 "  15. ^ \n" +
   2673 "  16. ^ \n" +
   2674 "  17. ^ \n";
   2675 
   2676 
   2677 var korean =
   2678 " \n" +
   2679 "    .\n" +
   2680 "   ,   1945       .\n" +
   2681 "\n" +
   2682 "  ()\n" +
   2683 "   ()\n" +
   2684 "   ()\n" +
   2685 "	 - \n" +
   2686 "\n" +
   2687 "\n" +
   2688 "\n" +
   2689 "\n" +
   2690 "|\n" +
   2691 "\n" +
   2692 "\n" +
   2693 "|\n" +
   2694 "\n" +
   2695 "\n" +
   2696 "\n" +
   2697 "|\n" +
   2698 "\n" +
   2699 "\n" +
   2700 "		\n" +
   2701 "	\n" +
   2702 "	\n" +
   2703 "\n" +
   2704 "\n" +
   2705 "	\n" +
   2706 "	\n" +
   2707 "\n" +
   2708 "	\n" +
   2709 "	\n" +
   2710 "\n" +
   2711 "\n" +
   2712 "\n" +
   2713 "\n" +
   2714 "	\n" +
   2715 "\n" +
   2716 "		\n" +
   2717 "\n" +
   2718 "		\n" +
   2719 "	\n" +
   2720 "\n" +
   2721 "\n" +
   2722 "	\n" +
   2723 "	\n" +
   2724 "\n" +
   2725 "\n" +
   2726 "\n" +
   2727 "\n" +
   2728 "\n" +
   2729 "\n" +
   2730 "\n" +
   2731 "\n" +
   2732 "\n" +
   2733 "  ()\n" +
   2734 "\n" +
   2735 "	\n" +
   2736 "\n" +
   2737 " \n" +
   2738 "       ,        .\n" +
   2739 " []\n" +
   2740 "1  \n" +
   2741 "1.1   \n" +
   2742 "1.2   \n" +
   2743 "2   (B.C. 2333 ~ A.D. 1)\n" +
   2744 "2.1  \n" +
   2745 "2.2     \n" +
   2746 "3   (A.D. 1~A.D. 900)\n" +
   2747 "3.1 \n" +
   2748 "3.1.1  \n" +
   2749 "3.1.2  \n" +
   2750 "3.2 \n" +
   2751 "4  (A.D. 918 ~ A.D. 1392)\n" +
   2752 "4.1  \n" +
   2753 "4.2  \n" +
   2754 "4.3  \n" +
   2755 "4.4  \n" +
   2756 "5  (A.D. 1392 ~ A.D. 1506)\n" +
   2757 "5.1   \n" +
   2758 "5.2   \n" +
   2759 "5.3   \n" +
   2760 "5.4   \n" +
   2761 "6   (A.D. 1506 ~ A.D. 1907)\n" +
   2762 "6.1   \n" +
   2763 "6.2   \n" +
   2764 "6.3   \n" +
   2765 "6.4   \n" +
   2766 "7  (A.D. 1907 ~ )\n" +
   2767 "7.1 \n" +
   2768 "7.2 \n" +
   2769 "7.3 \n" +
   2770 "8 \n" +
   2771 "9  \n" +
   2772 "10   \n" +
   2773 "10.1  \n" +
   2774 "10.2 , ,  \n" +
   2775 "[]\n" +
   2776 " \n" +
   2777 "\n" +
   2778 "[]\n" +
   2779 "  \n" +
   2780 "  (20   ~  1  )\n" +
   2781 "  ( 1   ~  4  )\n" +
   2782 ">>     ,    ,  ,         .\n" +
   2783 "[]\n" +
   2784 "  \n" +
   2785 " [1]()\n" +
   2786 "[2]    [3]()\n" +
   2787 "[]\n" +
   2788 "  (B.C. 2333 ~ A.D. 1)\n" +
   2789 "\n" +
   2790 "           ,  ,    ()  .     ,  ,    .      ,   .       .  4  , ,         ,    , , , ,         .\n" +
   2791 "[]\n" +
   2792 " \n" +
   2793 "\n" +
   2794 "\n" +
   2795 "          ,              ,     .\n" +
   2796 "[]\n" +
   2797 "    \n" +
   2798 "           .        ,             .\n" +
   2799 ": , , \n" +
   2800 "\n" +
   2801 "\n" +
   2802 ":\n" +
   2803 "\n" +
   2804 "\n" +
   2805 "\n" +
   2806 "[]\n" +
   2807 "  (A.D. 1~A.D. 900)\n" +
   2808 "\n" +
   2809 "[]\n" +
   2810 "\n" +
   2811 "\n" +
   2812 "\n" +
   2813 "\n" +
   2814 "             .\n" +
   2815 "[]\n" +
   2816 " \n" +
   2817 "        .[ ]\n" +
   2818 "      .\n" +
   2819 "[]\n" +
   2820 " \n" +
   2821 "        .\n" +
   2822 "[]\n" +
   2823 "\n" +
   2824 "\n" +
   2825 "\n" +
   2826 "[]\n" +
   2827 " (A.D. 918 ~ A.D. 1392)\n" +
   2828 "\n" +
   2829 "    .\n" +
   2830 "[]\n" +
   2831 " \n" +
   2832 "       .            .  (6 )            ,          . ,          .\n" +
   2833 "      .        . 12                    .\n" +
   2834 ",                    ,     .\n" +
   2835 "[]\n" +
   2836 " \n" +
   2837 "               . ,            .       ,        .\n" +
   2838 "     ,           .             .\n" +
   2839 "[]\n" +
   2840 " \n" +
   2841 "   , , ,  .    .    ,      .     ,             .\n" +
   2842 "      , , ,  . , ,            ,          .             ,       .\n" +
   2843 "[]\n" +
   2844 " \n" +
   2845 "               .\n" +
   2846 "   ,      ,    .        .     ,     .\n" +
   2847 "        .        ,      .          .\n" +
   2848 "[]\n" +
   2849 " (A.D. 1392 ~ A.D. 1506)\n" +
   2850 "\n" +
   2851 "      .\n" +
   2852 "[]\n" +
   2853 "  \n" +
   2854 "     .      .                 .  15     16           .          .\n" +
   2855 "         .      ,      .               .               .\n" +
   2856 "[]\n" +
   2857 "  \n" +
   2858 "                  .             .\n" +
   2859 "            ,        .             50    15  160  .             .\n" +
   2860 "         ,                              .          .\n" +
   2861 "[]\n" +
   2862 "  \n" +
   2863 "        .         ,    .  ()     .\n" +
   2864 "          .        .           ,       .            , , ,     .\n" +
   2865 "       .          ,           .\n" +
   2866 "[]\n" +
   2867 "  \n" +
   2868 "               .           ,              .\n" +
   2869 " ,      ,    . 15                    .            .\n" +
   2870 ",          ,       .\n" +
   2871 "      ,           .\n" +
   2872 "[]\n" +
   2873 "  (A.D. 1506 ~ A.D. 1907)\n" +
   2874 "\n" +
   2875 "       .\n" +
   2876 "[]\n" +
   2877 "  \n" +
   2878 "                .             .            .              ,     .\n" +
   2879 "                       .        .\n" +
   2880 "[]\n" +
   2881 "  \n" +
   2882 "      .         .            .   ,  ,    .\n" +
   2883 "           ,      .         .        .     ,     ,    .\n" +
   2884 "[]\n" +
   2885 "  \n" +
   2886 "               .               .                 .                 .                     .\n" +
   2887 "         .       , 19             [ ]      .               [ ]     .\n" +
   2888 "[]\n" +
   2889 "  \n" +
   2890 "           .                .\n" +
   2891 "                         .\n" +
   2892 "            .        .\n" +
   2893 "  , ,       ,       .             .\n" +
   2894 "[]\n" +
   2895 " (A.D. 1907 ~ )\n" +
   2896 "\n" +
   2897 "[]\n" +
   2898 "\n" +
   2899 "           19C     .   (), (), (), (), ()   ,  .\n" +
   2900 "            .         ,      .\n" +
   2901 " ,          . ,               .\n" +
   2902 "       , , ,          .      ,     .\n" +
   2903 "       .        ,    ,        .       1945 8  .\n" +
   2904 "       ,     .             .        .\n" +
   2905 "       ,     (), (), (), (), ()   .              ,       .\n" +
   2906 "            . ,         .        .\n" +
   2907 ",             . , 625           .\n" +
   2908 "   ,      .  419 518 , 6      .  ,          .\n" +
   2909 "1960       .      ,     .\n" +
   2910 "        ,     .    ,         .1980        ,     .\n" +
   2911 "        .              .\n" +
   2912 "    ,         . ,              .\n" +
   2913 "[]\n" +
   2914 "\n" +
   2915 " \n" +
   2916 " :        ,   ,   ,    .\n" +
   2917 "   :       ,           . , , ,    ,   . ,             .     ,           .       ,     .\n" +
   2918 "   : 31          ,    .         .     ,   .                 ,       .\n" +
   2919 "   : 1930         . , 1941        .        ,   ,        . ,          ,           .\n" +
   2920 "[]\n" +
   2921 "\n" +
   2922 " :         \n" +
   2923 "\n" +
   2924 "1\n" +
   2925 "\n" +
   2926 "2\n" +
   2927 "3\n" +
   2928 "4 - .   \n" +
   2929 "5\n" +
   2930 "1.  :  (    - 12.12 ) .   .       ,   1987 6  629(  )   .\n" +
   2931 "2.  : 1960~70  ,       .          ,     .\n" +
   2932 "3.  : 1986    , 1988      .\n" +
   2933 "6\n" +
   2934 " \n" +
   2935 "\n" +
   2936 " \n" +
   2937 "\n" +
   2938 "\n" +
   2939 " \n" +
   2940 "[]\n" +
   2941 "\n" +
   2942 "\n" +
   2943 "  -  1904 ,  - 1979 \n" +
   2944 "  -  ,  -  \n" +
   2945 "  - 1979 \n" +
   2946 "[]\n" +
   2947 " \n" +
   2948 "\n" +
   2949 " \n" +
   2950 " \n" +
   2951 "\n" +
   2952 "\n" +
   2953 "[]\n" +
   2954 "  \n" +
   2955 "\n" +
   2956 "[]\n" +
   2957 " \n" +
   2958 "   :    , ,    ,  , ,  ,    .  , ,  ,   \n" +
   2959 "   :   .,  . 2007      .\n" +
   2960 "    :  ,      ,  ,   \n" +
   2961 "   :            .   ,  ,  ,    \n" +
   2962 "   :    (  ),  ,  ,     \n" +
   2963 "[]\n" +
   2964 ", ,  \n" +
   2965 "  :         2004  . ,       , , ,   .     .\n" +
   2966 "   :  ,   ,        \n" +
   2967 "      : , , , ,    , , , ,  ,   \n" +
   2968 "      :   ,  ,  , , , ,       \n" +
   2969 " :       \n";
   2970 
   2971 
   2972 var persian =
   2973 "    \n" +
   2974 "   .\n" +
   2975 "   \n" +
   2976 "    \n" +
   2977 " \n" +
   2978 "    \n" +
   2979 " / \n" +
   2980 ":     \n" +
   2981 "      \n" +
   2982 "    \n" +
   2983 ":    \n" +
   2984 "    \n" +
   2985 "  \n" +
   2986 "  \n" +
   2987 "\n" +
   2988 " \n" +
   2989 " \n" +
   2990 " \n" +
   2991 " \n" +
   2992 " \n" +
   2993 " \n" +
   2994 "\n" +
   2995 " \n" +
   2996 "  \n" +
   2997 "  \n" +
   2998 " \n" +
   2999 " \n" +
   3000 "   \n" +
   3001 "\n" +
   3002 "                       .                            (  )            ( )     ( )       (  )   .                .\n" +
   3003 "                .               -   -  -      .\n" +
   3004 "  [ ]\n" +
   3005 " \n" +
   3006 "    \n" +
   3007 " \n" +
   3008 " \n" +
   3009 " \n" +
   3010 " \n" +
   3011 " \n" +
   3012 " \n" +
   3013 "  \n" +
   3014 "   \n" +
   3015 "[]\n" +
   3016 "\n" +
   3017 "\n" +
   3018 "         . .    . .            .                        .\n" +
   3019 "            .                        .       .\n" +
   3020 "                        . . .            .                                   .                   .\n" +
   3021 "       .                       .             .\n" +
   3022 "[]\n" +
   3023 "   \n" +
   3024 "\n" +
   3025 "             .                        .                (7000    )     4000      .\n" +
   3026 "        (  )    .                .                  .   5000                            :               .\n" +
   3027 "            :    (    )     (  )    (  )    (     )      (     )           (  )      (      )      (    )      (      )    (  )      (   )              (  )         (  )    ()              .                                          .\n" +
   3028 "    150  (708- 550 .)       (550-330 .)        (330 -250 .)     (250 .  226 )         (226-651 )  .\n" +
   3029 "[]\n" +
   3030 "\n" +
   3031 "\n" +
   3032 "\n" +
   3033 "\n" +
   3034 "  675   \n" +
   3035 "\n" +
   3036 "\n" +
   3037 "  600   \n" +
   3038 "              .        .                      .                   \n" +
   3039 "                    .\n" +
   3040 "                             .\n" +
   3041 "                  .           :            .\n" +
   3042 "[]\n" +
   3043 "\n" +
   3044 "\n" +
   3045 "\n" +
   3046 "\n" +
   3047 "    330 ..\n" +
   3048 "                                   .          .\n" +
   3049 "  .               .                      .      : \"     ()      ...\"\n" +
   3050 "            .               : \"           :        ( )  ().\"   9   522  19  520 .      .\n" +
   3051 "        .      330 .              .\n" +
   3052 "                                 327- 329 .                .          .                             .\n" +
   3053 "\n" +
   3054 "\n" +
   3055 " \n" +
   3056 "   	\n" +
   3057 "    	\n" +
   3058 "    |   \n" +
   3059 "\n" +
   3060 "\n" +
   3061 "\n" +
   3062 "\n" +
   3063 "\n" +
   3064 "\n" +
   3065 "    	\n" +
   3066 "    |   \n" +
   3067 " \n" +
   3068 "\n" +
   3069 "\n" +
   3070 "    	\n" +
   3071 "    |   \n" +
   3072 "\n" +
   3073 "\n" +
   3074 "\n" +
   3075 " \n" +
   3076 " \n" +
   3077 "\n" +
   3078 "\n" +
   3079 "\n" +
   3080 "   	\n" +
   3081 "    |   \n" +
   3082 "\n" +
   3083 "   	\n" +
   3084 "    |   \n" +
   3085 "\n" +
   3086 "\n" +
   3087 "\n" +
   3088 "\n" +
   3089 "\n" +
   3090 "\n" +
   3091 "    	\n" +
   3092 "    |   \n" +
   3093 "\n" +
   3094 "\n" +
   3095 "\n" +
   3096 "\n" +
   3097 "\n" +
   3098 " \n" +
   3099 "\n" +
   3100 "  \n" +
   3101 "  \n" +
   3102 "\n" +
   3103 "\n" +
   3104 "\n" +
   3105 "\n" +
   3106 "\n" +
   3107 " \n" +
   3108 "    \n" +
   3109 " \n" +
   3110 "  \n" +
   3111 " \n" +
   3112 "  \n" +
   3113 " \n" +
   3114 "[]\n" +
   3115 "\n" +
   3116 "\n" +
   3117 "\n" +
   3118 "    (330 - 150 ..)\n" +
   3119 "    (323 . )                   .        (330 - 150 ..)  .                     .\n" +
   3120 "[]\n" +
   3121 "\n" +
   3122 "\n" +
   3123 "\n" +
   3124 "\n" +
   3125 "  250 .. 224 .\n" +
   3126 " (250 .  224 )                             .               .                     .                                 .                             .\n" +
   3127 "                  .         .                       .\n" +
   3128 "[]\n" +
   3129 "\n" +
   3130 "\n" +
   3131 "\n" +
   3132 "\n" +
   3133 "       .\n" +
   3134 "          .                 .           .\n" +
   3135 "        .         652     .                  .          .\n" +
   3136 "\n" +
   3137 "   [1] (216 - 276 )     .                                    \"\"            .         :          .    )                  (                           .                               \"\"  \"\"           .\n" +
   3138 "                                 .                                     ( 276 ).               () .                    .\n" +
   3139 "\n" +
   3140 "                   .       .                             .\n" +
   3141 "                       ( 24-494 .)           .\n" +
   3142 "   [2]              .        :\n" +
   3143 "                            .\n" +
   3144 "      :     .\n" +
   3145 "       .                              .\n" +
   3146 "[]\n" +
   3147 "\n" +
   3148 "\n" +
   3149 "  -  \n" +
   3150 "  .  . (   ) 1354\n" +
   3151 " .   .    :  .\n" +
   3152 "  .   .  .       1380\n" +
   3153 "              .\n" +
   3154 " .     .   .     1379\n" +
   3155 "       . .  - . .     :  1385\n" +
   3156 "       18      1353.\n" +
   3157 "[]\n" +
   3158 " \n" +
   3159 "\n" +
   3160 "\n" +
   3161 "\n" +
   3162 "\n" +
   3163 " \n" +
   3164 " \n" +
   3165 "   \n" +
   3166 "   \n" +
   3167 "[]\n" +
   3168 "  \n" +
   3169 "\n" +
   3170 "   \n" +
   3171 "   \n" +
   3172 "    \n" +
   3173 "  \n" +
   3174 "    \n" +
   3175 "    \n" +
   3176 "  \n" +
   3177 "    \n" +
   3178 "  \n" +
   3179 "        \n" +
   3180 "\n" +
   3181 "[3]\n" +
   3182 "[4]\n" +
   3183 "[5]\n" +
   3184 "[6]\n" +
   3185 "[7]\n" +
   3186 "\n" +
   3187 "\n" +
   3188 "\n" +
   3189 "    .       .\n" +
   3190 "\n" +
   3191 "    .            .          .\n";
   3192 
   3193 
   3194 var source =
   3195 ("/*\n" +
   3196 "  This is a version (aka dlmalloc) of malloc/free/realloc written by\n" +
   3197 "  Doug Lea and released to the public domain.  Use, modify, and\n" +
   3198 "  redistribute this code without permission or acknowledgement in any\n" +
   3199 "  way you wish.  Send questions, comments, complaints, performance\n" +
   3200 "  data, etc to dl (a] cs.oswego.edu\n" +
   3201 "\n" +
   3202 "* VERSION 2.7.2 Sat Aug 17 09:07:30 2002  Doug Lea  (dl at gee)\n" +
   3203 "\n" +
   3204 "   Note: There may be an updated version of this malloc obtainable at\n" +
   3205 "           ftp://gee.cs.oswego.edu/pub/misc/malloc.c\n" +
   3206 "         Check before installing!\n" +
   3207 "\n" +
   3208 "* Quickstart\n" +
   3209 "\n" +
   3210 "  This library is all in one file to simplify the most common usage:\n" +
   3211 "  ftp it, compile it (-O), and link it into another program. All\n" +
   3212 "  of the compile-time options default to reasonable values for use on\n" +
   3213 "  most unix platforms. Compile -DWIN32 for reasonable defaults on windows.\n" +
   3214 "  You might later want to step through various compile-time and dynamic\n" +
   3215 "  tuning options.\n" +
   3216 "\n" +
   3217 "  For convenience, an include file for code using this malloc is at:\n" +
   3218 "     ftp://gee.cs.oswego.edu/pub/misc/malloc-2.7.1.h\n" +
   3219 "  You don't really need this .h file unless you call functions not\n" +
   3220 "  defined in your system include files.  The .h file contains only the\n" +
   3221 "  excerpts from this file needed for using this malloc on ANSI C/C++\n" +
   3222 "  systems, so long as you haven't changed compile-time options about\n" +
   3223 "  naming and tuning parameters.  If you do, then you can create your\n" +
   3224 "  own malloc.h that does include all settings by cutting at the point\n" +
   3225 "  indicated below.\n" +
   3226 "\n" +
   3227 "* Why use this malloc?\n" +
   3228 "\n" +
   3229 "  This is not the fastest, most space-conserving, most portable, or\n" +
   3230 "  most tunable malloc ever written. However it is among the fastest\n" +
   3231 "  while also being among the most space-conserving, portable and tunable.\n" +
   3232 "  Consistent balance across these factors results in a good general-purpose\n" +
   3233 "  allocator for malloc-intensive programs.\n" +
   3234 "\n" +
   3235 "  The main properties of the algorithms are:\n" +
   3236 "  * For large (>= 512 bytes) requests, it is a pure best-fit allocator,\n" +
   3237 "    with ties normally decided via FIFO (i.e. least recently used).\n" +
   3238 "  * For small (<= 64 bytes by default) requests, it is a caching\n" +
   3239 "    allocator, that maintains pools of quickly recycled chunks.\n" +
   3240 "  * In between, and for combinations of large and small requests, it does\n" +
   3241 "    the best it can trying to meet both goals at once.\n" +
   3242 "  * For very large requests (>= 128KB by default), it relies on system\n" +
   3243 "    memory mapping facilities, if supported.\n" +
   3244 "\n" +
   3245 "  For a longer but slightly out of date high-level description, see\n" +
   3246 "     http://gee.cs.oswego.edu/dl/html/malloc.html\n" +
   3247 "\n" +
   3248 "  You may already by default be using a C library containing a malloc\n" +
   3249 "  that is  based on some version of this malloc (for example in\n" +
   3250 "  linux). You might still want to use the one in this file in order to\n" +
   3251 "  customize settings or to avoid overheads associated with library\n" +
   3252 "  versions.\n" +
   3253 "\n" +
   3254 "* Contents, described in more detail in \"description of public routines\" below.\n" +
   3255 "\n" +
   3256 "  Standard (ANSI/SVID/...)  functions:\n" +
   3257 "    malloc(size_t n);\n" +
   3258 "    calloc(size_t n_elements, size_t element_size);\n" +
   3259 "    free(Void_t* p);\n" +
   3260 "    realloc(Void_t* p, size_t n);\n" +
   3261 "    memalign(size_t alignment, size_t n);\n" +
   3262 "    valloc(size_t n);\n" +
   3263 "    mallinfo()\n" +
   3264 "    mallopt(int parameter_number, int parameter_value)\n" +
   3265 "\n" +
   3266 "  Additional functions:\n" +
   3267 "    independent_calloc(size_t n_elements, size_t size, Void_t* chunks[]);\n" +
   3268 "    independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]);\n" +
   3269 "    pvalloc(size_t n);\n" +
   3270 "    cfree(Void_t* p);\n" +
   3271 "    malloc_trim(size_t pad);\n" +
   3272 "    malloc_usable_size(Void_t* p);\n" +
   3273 "    malloc_stats();\n" +
   3274 "\n" +
   3275 "* Vital statistics:\n" +
   3276 "\n" +
   3277 "  Supported pointer representation:       4 or 8 bytes\n" +
   3278 "  Supported size_t  representation:       4 or 8 bytes\n" +
   3279 "       Note that size_t is allowed to be 4 bytes even if pointers are 8.\n" +
   3280 "       You can adjust this by defining INTERNAL_SIZE_T\n" +
   3281 "\n" +
   3282 "  Alignment:                              2 * sizeof(size_t) (default)\n" +
   3283 "       (i.e., 8 byte alignment with 4byte size_t). This suffices for\n" +
   3284 "       nearly all current machines and C compilers. However, you can\n" +
   3285 "       define MALLOC_ALIGNMENT to be wider than this if necessary.\n" +
   3286 "\n" +
   3287 "  Minimum overhead per allocated chunk:   4 or 8 bytes\n" +
   3288 "       Each malloced chunk has a hidden word of overhead holding size\n" +
   3289 "       and status information.\n" +
   3290 "\n" +
   3291 "  Minimum allocated size: 4-byte ptrs:  16 bytes    (including 4 overhead)\n" +
   3292 "                          8-byte ptrs:  24/32 bytes (including, 4/8 overhead)\n" +
   3293 "\n" +
   3294 "       When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte\n" +
   3295 "       ptrs but 4 byte size) or 24 (for 8/8) additional bytes are\n" +
   3296 "       needed; 4 (8) for a trailing size field and 8 (16) bytes for\n" +
   3297 "       free list pointers. Thus, the minimum allocatable size is\n" +
   3298 "       16/24/32 bytes.\n" +
   3299 "\n" +
   3300 "       Even a request for zero bytes (i.e., malloc(0)) returns a\n" +
   3301 "       pointer to something of the minimum allocatable size.\n" +
   3302 "\n" +
   3303 "       The maximum overhead wastage (i.e., number of extra bytes\n" +
   3304 "       allocated than were requested in malloc) is less than or equal\n" +
   3305 "       to the minimum size, except for requests >= mmap_threshold that\n" +
   3306 "       are serviced via mmap(), where the worst case wastage is 2 *\n" +
   3307 "       sizeof(size_t) bytes plus the remainder from a system page (the\n" +
   3308 "       minimal mmap unit); typically 4096 or 8192 bytes.\n" +
   3309 "\n" +
   3310 "  Maximum allocated size:  4-byte size_t: 2^32 minus about two pages\n" +
   3311 "                           8-byte size_t: 2^64 minus about two pages\n" +
   3312 "\n" +
   3313 "       It is assumed that (possibly signed) size_t values suffice to\n" +
   3314 "       represent chunk sizes. `Possibly signed' is due to the fact\n" +
   3315 "       that `size_t' may be defined on a system as either a signed or\n" +
   3316 "       an unsigned type. The ISO C standard says that it must be\n" +
   3317 "       unsigned, but a few systems are known not to adhere to this.\n" +
   3318 "       Additionally, even when size_t is unsigned, sbrk (which is by\n" +
   3319 "       default used to obtain memory from system) accepts signed\n" +
   3320 "       arguments, and may not be able to handle size_t-wide arguments\n" +
   3321 "       with negative sign bit.  Generally, values that would\n" +
   3322 "       appear as negative after accounting for overhead and alignment\n" +
   3323 "       are supported only via mmap(), which does not have this\n" +
   3324 "       limitation.\n" +
   3325 "\n" +
   3326 "       Requests for sizes outside the allowed range will perform an optional\n" +
   3327 "       failure action and then return null. (Requests may also\n" +
   3328 "       also fail because a system is out of memory.)\n" +
   3329 "\n" +
   3330 "  Thread-safety: NOT thread-safe unless USE_MALLOC_LOCK defined\n" +
   3331 "\n" +
   3332 "       When USE_MALLOC_LOCK is defined, wrappers are created to\n" +
   3333 "       surround every public call with either a pthread mutex or\n" +
   3334 "       a win32 spinlock (depending on WIN32). This is not\n" +
   3335 "       especially fast, and can be a major bottleneck.\n" +
   3336 "       It is designed only to provide minimal protection\n" +
   3337 "       in concurrent environments, and to provide a basis for\n" +
   3338 "       extensions.  If you are using malloc in a concurrent program,\n" +
   3339 "       you would be far better off obtaining ptmalloc, which is\n" +
   3340 "       derived from a version of this malloc, and is well-tuned for\n" +
   3341 "       concurrent programs. (See http://www.malloc.de) Note that\n" +
   3342 "       even when USE_MALLOC_LOCK is defined, you can can guarantee\n" +
   3343 "       full thread-safety only if no threads acquire memory through\n" +
   3344 "       direct calls to MORECORE or other system-level allocators.\n" +
   3345 "\n" +
   3346 "  Compliance: I believe it is compliant with the 1997 Single Unix Specification\n" +
   3347 "       (See http://www.opennc.org). Also SVID/XPG, ANSI C, and probably\n" +
   3348 "       others as well.\n" +
   3349 "\n" +
   3350 "* Synopsis of compile-time options:\n" +
   3351 "\n" +
   3352 "    People have reported using previous versions of this malloc on all\n" +
   3353 "    versions of Unix, sometimes by tweaking some of the defines\n" +
   3354 "    below. It has been tested most extensively on Solaris and\n" +
   3355 "    Linux. It is also reported to work on WIN32 platforms.\n" +
   3356 "    People also report using it in stand-alone embedded systems.\n" +
   3357 "\n" +
   3358 "    The implementation is in straight, hand-tuned ANSI C.  It is not\n" +
   3359 "    at all modular. (Sorry!)  It uses a lot of macros.  To be at all\n" +
   3360 "    usable, this code should be compiled using an optimizing compiler\n" +
   3361 "    (for example gcc -O3) that can simplify expressions and control\n" +
   3362 "    paths. (FAQ: some macros import variables as arguments rather than\n" +
   3363 "    declare locals because people reported that some debuggers\n" +
   3364 "    otherwise get confused.)\n" +
   3365 "\n" +
   3366 "    OPTION                     DEFAULT VALUE\n" +
   3367 "\n" +
   3368 "    Compilation Environment options:\n" +
   3369 "\n" +
   3370 "    __STD_C                    derived from C compiler defines\n" +
   3371 "    WIN32                      NOT defined\n" +
   3372 "    HAVE_MEMCPY                defined\n" +
   3373 "    USE_MEMCPY                 1 if HAVE_MEMCPY is defined\n" +
   3374 "    HAVE_MMAP                  defined as 1\n" +
   3375 "    MMAP_CLEARS                1\n" +
   3376 "    HAVE_MREMAP                0 unless linux defined\n" +
   3377 "    malloc_getpagesize         derived from system #includes, or 4096 if not\n" +
   3378 "    HAVE_USR_INCLUDE_MALLOC_H  NOT defined\n" +
   3379 "    LACKS_UNISTD_H             NOT defined unless WIN32\n" +
   3380 "    LACKS_SYS_PARAM_H          NOT defined unless WIN32\n" +
   3381 "    LACKS_SYS_MMAN_H           NOT defined unless WIN32\n" +
   3382 "    LACKS_FCNTL_H              NOT defined\n" +
   3383 "\n" +
   3384 "    Changing default word sizes:\n" +
   3385 "\n" +
   3386 "    INTERNAL_SIZE_T            size_t\n" +
   3387 "    MALLOC_ALIGNMENT           2 * sizeof(INTERNAL_SIZE_T)\n" +
   3388 "    PTR_UINT                   unsigned long\n" +
   3389 "    CHUNK_SIZE_T               unsigned long\n" +
   3390 "\n" +
   3391 "    Configuration and functionality options:\n" +
   3392 "\n" +
   3393 "    USE_DL_PREFIX              NOT defined\n" +
   3394 "    USE_PUBLIC_MALLOC_WRAPPERS NOT defined\n" +
   3395 "    USE_MALLOC_LOCK            NOT defined\n" +
   3396 "    DEBUG                      NOT defined\n" +
   3397 "    REALLOC_ZERO_BYTES_FREES   NOT defined\n" +
   3398 "    MALLOC_FAILURE_ACTION      errno = ENOMEM, if __STD_C defined, else no-op\n" +
   3399 "    TRIM_FASTBINS              0\n" +
   3400 "    FIRST_SORTED_BIN_SIZE      512\n" +
   3401 "\n" +
   3402 "    Options for customizing MORECORE:\n" +
   3403 "\n" +
   3404 "    MORECORE                   sbrk\n" +
   3405 "    MORECORE_CONTIGUOUS        1\n" +
   3406 "    MORECORE_CANNOT_TRIM       NOT defined\n" +
   3407 "    MMAP_AS_MORECORE_SIZE      (1024 * 1024)\n" +
   3408 "\n" +
   3409 "    Tuning options that are also dynamically changeable via mallopt:\n" +
   3410 "\n" +
   3411 "    DEFAULT_MXFAST             64\n" +
   3412 "    DEFAULT_TRIM_THRESHOLD     256 * 1024\n" +
   3413 "    DEFAULT_TOP_PAD            0\n" +
   3414 "    DEFAULT_MMAP_THRESHOLD     256 * 1024\n" +
   3415 "    DEFAULT_MMAP_MAX           65536\n" +
   3416 "\n" +
   3417 "    There are several other #defined constants and macros that you\n" +
   3418 "    probably don't want to touch unless you are extending or adapting malloc.\n" +
   3419 "*/\n" +
   3420 "\n" +
   3421 "#define MORECORE_CONTIGUOUS 0\n" +
   3422 "#define MORECORE_CANNOT_TRIM 1\n" +
   3423 "#define MALLOC_FAILURE_ACTION abort()\n" +
   3424 "\n" +
   3425 "\n" +
   3426 "namespace khtml {\n" +
   3427 "\n" +
   3428 "#ifndef NDEBUG\n" +
   3429 "\n" +
   3430 "// In debugging builds, use the system malloc for its debugging features.\n" +
   3431 "\n" +
   3432 "void *main_thread_malloc(size_t n)\n" +
   3433 "{\n" +
   3434 "    assert(pthread_main_np());\n" +
   3435 "    return malloc(n);\n" +
   3436 "}\n" +
   3437 "\n" +
   3438 "void *main_thread_calloc(size_t n_elements, size_t element_size)\n" +
   3439 "{\n" +
   3440 "    assert(pthread_main_np());\n" +
   3441 "    return calloc(n_elements, element_size);\n" +
   3442 "}\n" +
   3443 "\n" +
   3444 "void main_thread_free(void* p)\n" +
   3445 "{\n" +
   3446 "    // it's ok to main_thread_free on a non-main thread - the actual\n" +
   3447 "    // free will be scheduled on the main thread in that case.\n" +
   3448 "    free(p);\n" +
   3449 "}\n" +
   3450 "\n" +
   3451 "void *main_thread_realloc(void* p, size_t n)\n" +
   3452 "{\n" +
   3453 "    assert(pthread_main_np());\n" +
   3454 "    return realloc(p, n);\n" +
   3455 "}\n" +
   3456 "\n" +
   3457 "#else\n" +
   3458 "\n" +
   3459 "/*\n" +
   3460 "  WIN32 sets up defaults for MS environment and compilers.\n" +
   3461 "  Otherwise defaults are for unix.\n" +
   3462 "*/\n" +
   3463 "\n" +
   3464 "/* #define WIN32 */\n" +
   3465 "\n" +
   3466 "#ifdef WIN32\n" +
   3467 "\n" +
   3468 "#define WIN32_LEAN_AND_MEAN\n" +
   3469 "#include <windows.h>\n" +
   3470 "\n" +
   3471 "/* Win32 doesn't supply or need the following headers */\n" +
   3472 "#define LACKS_UNISTD_H\n" +
   3473 "#define LACKS_SYS_PARAM_H\n" +
   3474 "#define LACKS_SYS_MMAN_H\n" +
   3475 "\n" +
   3476 "/* Use the supplied emulation of sbrk */\n" +
   3477 "#define MORECORE sbrk\n" +
   3478 "#define MORECORE_CONTIGUOUS 1\n" +
   3479 "#define MORECORE_FAILURE    ((void*)(-1))\n" +
   3480 "\n" +
   3481 "/* Use the supplied emulation of mmap and munmap */\n" +
   3482 "#define HAVE_MMAP 1\n" +
   3483 "#define MUNMAP_FAILURE  (-1)\n" +
   3484 "#define MMAP_CLEARS 1\n" +
   3485 "\n" +
   3486 "/* These values don't really matter in windows mmap emulation */\n" +
   3487 "#define MAP_PRIVATE 1\n" +
   3488 "#define MAP_ANONYMOUS 2\n" +
   3489 "#define PROT_READ 1\n" +
   3490 "#define PROT_WRITE 2\n" +
   3491 "\n" +
   3492 "/* Emulation functions defined at the end of this file */\n" +
   3493 "\n" +
   3494 "/* If USE_MALLOC_LOCK, use supplied critical-section-based lock functions */\n" +
   3495 "#ifdef USE_MALLOC_LOCK\n") +
   3496 ("static int slwait(int *sl);\n" +
   3497 "static int slrelease(int *sl);\n" +
   3498 "#endif\n" +
   3499 "\n" +
   3500 "static long getpagesize(void);\n" +
   3501 "static long getregionsize(void);\n" +
   3502 "static void *sbrk(long size);\n" +
   3503 "static void *mmap(void *ptr, long size, long prot, long type, long handle, long arg);\n" +
   3504 "static long munmap(void *ptr, long size);\n" +
   3505 "\n" +
   3506 "static void vminfo (unsigned long*free, unsigned long*reserved, unsigned long*committed);\n" +
   3507 "static int cpuinfo (int whole, unsigned long*kernel, unsigned long*user);\n" +
   3508 "\n" +
   3509 "#endif\n" +
   3510 "\n" +
   3511 "/*\n" +
   3512 "  __STD_C should be nonzero if using ANSI-standard C compiler, a C++\n" +
   3513 "  compiler, or a C compiler sufficiently close to ANSI to get away\n" +
   3514 "  with it.\n" +
   3515 "*/\n" +
   3516 "\n" +
   3517 "#ifndef __STD_C\n" +
   3518 "#if defined(__STDC__) || defined(_cplusplus)\n" +
   3519 "#define __STD_C     1\n" +
   3520 "#else\n" +
   3521 "#define __STD_C     0\n" +
   3522 "#endif\n" +
   3523 "#endif /*__STD_C*/\n" +
   3524 "\n" +
   3525 "\n" +
   3526 "/*\n" +
   3527 "  Void_t* is the pointer type that malloc should say it returns\n" +
   3528 "*/\n" +
   3529 "\n" +
   3530 "#ifndef Void_t\n" +
   3531 "#if (__STD_C || defined(WIN32))\n" +
   3532 "#define Void_t      void\n" +
   3533 "#else\n" +
   3534 "#define Void_t      char\n" +
   3535 "#endif\n" +
   3536 "#endif /*Void_t*/\n" +
   3537 "\n" +
   3538 "#if __STD_C\n" +
   3539 "#include <stddef.h>   /* for size_t */\n" +
   3540 "#else\n" +
   3541 "#include <sys/types.h>\n" +
   3542 "#endif\n" +
   3543 "\n" +
   3544 "/* define LACKS_UNISTD_H if your system does not have a <unistd.h>. */\n" +
   3545 "\n" +
   3546 "/* #define  LACKS_UNISTD_H */\n" +
   3547 "\n" +
   3548 "#ifndef LACKS_UNISTD_H\n" +
   3549 "#include <unistd.h>\n" +
   3550 "#endif\n" +
   3551 "\n" +
   3552 "/* define LACKS_SYS_PARAM_H if your system does not have a <sys/param.h>. */\n" +
   3553 "\n" +
   3554 "/* #define  LACKS_SYS_PARAM_H */\n" +
   3555 "\n" +
   3556 "\n" +
   3557 "#include <stdio.h>    /* needed for malloc_stats */\n" +
   3558 "#include <errno.h>    /* needed for optional MALLOC_FAILURE_ACTION */\n" +
   3559 "\n" +
   3560 "\n" +
   3561 "/*\n" +
   3562 "  Debugging:\n" +
   3563 "\n" +
   3564 "  Because freed chunks may be overwritten with bookkeeping fields, this\n" +
   3565 "  malloc will often die when freed memory is overwritten by user\n" +
   3566 "  programs.  This can be very effective (albeit in an annoying way)\n" +
   3567 "  in helping track down dangling pointers.\n" +
   3568 "\n" +
   3569 "  If you compile with -DDEBUG, a number of assertion checks are\n" +
   3570 "  enabled that will catch more memory errors. You probably won't be\n" +
   3571 "  able to make much sense of the actual assertion errors, but they\n" +
   3572 "  should help you locate incorrectly overwritten memory.  The\n" +
   3573 "  checking is fairly extensive, and will slow down execution\n" +
   3574 "  noticeably. Calling malloc_stats or mallinfo with DEBUG set will\n" +
   3575 "  attempt to check every non-mmapped allocated and free chunk in the\n" +
   3576 "  course of computing the summmaries. (By nature, mmapped regions\n" +
   3577 "  cannot be checked very much automatically.)\n" +
   3578 "\n" +
   3579 "  Setting DEBUG may also be helpful if you are trying to modify\n" +
   3580 "  this code. The assertions in the check routines spell out in more\n" +
   3581 "  detail the assumptions and invariants underlying the algorithms.\n" +
   3582 "\n" +
   3583 "  Setting DEBUG does NOT provide an automated mechanism for checking\n" +
   3584 "  that all accesses to malloced memory stay within their\n" +
   3585 "  bounds. However, there are several add-ons and adaptations of this\n" +
   3586 "  or other mallocs available that do this.\n" +
   3587 "*/\n" +
   3588 "\n" +
   3589 "/*\n" +
   3590 "  The unsigned integer type used for comparing any two chunk sizes.\n" +
   3591 "  This should be at least as wide as size_t, but should not be signed.\n" +
   3592 "*/\n" +
   3593 "\n" +
   3594 "#ifndef CHUNK_SIZE_T\n" +
   3595 "#define CHUNK_SIZE_T unsigned long\n" +
   3596 "#endif\n" +
   3597 "\n" +
   3598 "/*\n" +
   3599 "  The unsigned integer type used to hold addresses when they are are\n" +
   3600 "  manipulated as integers. Except that it is not defined on all\n" +
   3601 "  systems, intptr_t would suffice.\n" +
   3602 "*/\n" +
   3603 "#ifndef PTR_UINT\n" +
   3604 "#define PTR_UINT unsigned long\n" +
   3605 "#endif\n" +
   3606 "\n" +
   3607 "\n" +
   3608 "/*\n" +
   3609 "  INTERNAL_SIZE_T is the word-size used for internal bookkeeping\n" +
   3610 "  of chunk sizes.\n" +
   3611 "\n" +
   3612 "  The default version is the same as size_t.\n" +
   3613 "\n" +
   3614 "  While not strictly necessary, it is best to define this as an\n" +
   3615 "  unsigned type, even if size_t is a signed type. This may avoid some\n" +
   3616 "  artificial size limitations on some systems.\n" +
   3617 "\n" +
   3618 "  On a 64-bit machine, you may be able to reduce malloc overhead by\n" +
   3619 "  defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' at the\n" +
   3620 "  expense of not being able to handle more than 2^32 of malloced\n" +
   3621 "  space. If this limitation is acceptable, you are encouraged to set\n" +
   3622 "  this unless you are on a platform requiring 16byte alignments. In\n" +
   3623 "  this case the alignment requirements turn out to negate any\n" +
   3624 "  potential advantages of decreasing size_t word size.\n" +
   3625 "\n" +
   3626 "  Implementors: Beware of the possible combinations of:\n" +
   3627 "     - INTERNAL_SIZE_T might be signed or unsigned, might be 32 or 64 bits,\n" +
   3628 "       and might be the same width as int or as long\n" +
   3629 "     - size_t might have different width and signedness as INTERNAL_SIZE_T\n" +
   3630 "     - int and long might be 32 or 64 bits, and might be the same width\n" +
   3631 "  To deal with this, most comparisons and difference computations\n" +
   3632 "  among INTERNAL_SIZE_Ts should cast them to CHUNK_SIZE_T, being\n" +
   3633 "  aware of the fact that casting an unsigned int to a wider long does\n" +
   3634 "  not sign-extend. (This also makes checking for negative numbers\n" +
   3635 "  awkward.) Some of these casts result in harmless compiler warnings\n" +
   3636 "  on some systems.\n" +
   3637 "*/\n" +
   3638 "\n" +
   3639 "#ifndef INTERNAL_SIZE_T\n" +
   3640 "#define INTERNAL_SIZE_T size_t\n" +
   3641 "#endif\n" +
   3642 "\n" +
   3643 "/* The corresponding word size */\n" +
   3644 "#define SIZE_SZ                (sizeof(INTERNAL_SIZE_T))\n" +
   3645 "\n" +
   3646 "\n") +
   3647 ("\n" +
   3648 "/*\n" +
   3649 "  MALLOC_ALIGNMENT is the minimum alignment for malloc'ed chunks.\n" +
   3650 "  It must be a power of two at least 2 * SIZE_SZ, even on machines\n" +
   3651 "  for which smaller alignments would suffice. It may be defined as\n" +
   3652 "  larger than this though. Note however that code and data structures\n" +
   3653 "  are optimized for the case of 8-byte alignment.\n" +
   3654 "*/\n" +
   3655 "\n" +
   3656 "\n" +
   3657 "#ifndef MALLOC_ALIGNMENT\n" +
   3658 "#define MALLOC_ALIGNMENT       (2 * SIZE_SZ)\n" +
   3659 "#endif\n" +
   3660 "\n" +
   3661 "/* The corresponding bit mask value */\n" +
   3662 "#define MALLOC_ALIGN_MASK      (MALLOC_ALIGNMENT - 1)\n" +
   3663 "\n" +
   3664 "\n" +
   3665 "\n" +
   3666 "/*\n" +
   3667 "  REALLOC_ZERO_BYTES_FREES should be set if a call to\n" +
   3668 "  realloc with zero bytes should be the same as a call to free.\n" +
   3669 "  Some people think it should. Otherwise, since this malloc\n" +
   3670 "  returns a unique pointer for malloc(0), so does realloc(p, 0).\n" +
   3671 "*/\n" +
   3672 "\n" +
   3673 "/*   #define REALLOC_ZERO_BYTES_FREES */\n" +
   3674 "\n" +
   3675 "/*\n" +
   3676 "  TRIM_FASTBINS controls whether free() of a very small chunk can\n" +
   3677 "  immediately lead to trimming. Setting to true (1) can reduce memory\n" +
   3678 "  footprint, but will almost always slow down programs that use a lot\n" +
   3679 "  of small chunks.\n" +
   3680 "\n" +
   3681 "  Define this only if you are willing to give up some speed to more\n" +
   3682 "  aggressively reduce system-level memory footprint when releasing\n" +
   3683 "  memory in programs that use many small chunks.  You can get\n" +
   3684 "  essentially the same effect by setting MXFAST to 0, but this can\n" +
   3685 "  lead to even greater slowdowns in programs using many small chunks.\n" +
   3686 "  TRIM_FASTBINS is an in-between compile-time option, that disables\n" +
   3687 "  only those chunks bordering topmost memory from being placed in\n" +
   3688 "  fastbins.\n" +
   3689 "*/\n" +
   3690 "\n" +
   3691 "#ifndef TRIM_FASTBINS\n" +
   3692 "#define TRIM_FASTBINS  0\n" +
   3693 "#endif\n" +
   3694 "\n" +
   3695 "\n" +
   3696 "/*\n" +
   3697 "  USE_DL_PREFIX will prefix all public routines with the string 'dl'.\n" +
   3698 "  This is necessary when you only want to use this malloc in one part\n" +
   3699 "  of a program, using your regular system malloc elsewhere.\n" +
   3700 "*/\n" +
   3701 "\n" +
   3702 "#define USE_DL_PREFIX\n" +
   3703 "\n" +
   3704 "\n" +
   3705 "/*\n" +
   3706 "  USE_MALLOC_LOCK causes wrapper functions to surround each\n" +
   3707 "  callable routine with pthread mutex lock/unlock.\n" +
   3708 "\n" +
   3709 "  USE_MALLOC_LOCK forces USE_PUBLIC_MALLOC_WRAPPERS to be defined\n" +
   3710 "*/\n" +
   3711 "\n" +
   3712 "\n" +
   3713 "/* #define USE_MALLOC_LOCK */\n" +
   3714 "\n" +
   3715 "\n" +
   3716 "/*\n" +
   3717 "  If USE_PUBLIC_MALLOC_WRAPPERS is defined, every public routine is\n" +
   3718 "  actually a wrapper function that first calls MALLOC_PREACTION, then\n" +
   3719 "  calls the internal routine, and follows it with\n" +
   3720 "  MALLOC_POSTACTION. This is needed for locking, but you can also use\n" +
   3721 "  this, without USE_MALLOC_LOCK, for purposes of interception,\n" +
   3722 "  instrumentation, etc. It is a sad fact that using wrappers often\n" +
   3723 "  noticeably degrades performance of malloc-intensive programs.\n" +
   3724 "*/\n" +
   3725 "\n" +
   3726 "#ifdef USE_MALLOC_LOCK\n" +
   3727 "#define USE_PUBLIC_MALLOC_WRAPPERS\n" +
   3728 "#else\n" +
   3729 "/* #define USE_PUBLIC_MALLOC_WRAPPERS */\n" +
   3730 "#endif\n" +
   3731 "\n" +
   3732 "\n" +
   3733 "/*\n" +
   3734 "   Two-phase name translation.\n" +
   3735 "   All of the actual routines are given mangled names.\n" +
   3736 "   When wrappers are used, they become the public callable versions.\n" +
   3737 "   When DL_PREFIX is used, the callable names are prefixed.\n" +
   3738 "*/\n" +
   3739 "\n" +
   3740 "#ifndef USE_PUBLIC_MALLOC_WRAPPERS\n" +
   3741 "#define cALLOc      public_cALLOc\n" +
   3742 "#define fREe        public_fREe\n" +
   3743 "#define cFREe       public_cFREe\n" +
   3744 "#define mALLOc      public_mALLOc\n" +
   3745 "#define mEMALIGn    public_mEMALIGn\n" +
   3746 "#define rEALLOc     public_rEALLOc\n" +
   3747 "#define vALLOc      public_vALLOc\n" +
   3748 "#define pVALLOc     public_pVALLOc\n" +
   3749 "#define mALLINFo    public_mALLINFo\n" +
   3750 "#define mALLOPt     public_mALLOPt\n" +
   3751 "#define mTRIm       public_mTRIm\n" +
   3752 "#define mSTATs      public_mSTATs\n" +
   3753 "#define mUSABLe     public_mUSABLe\n" +
   3754 "#define iCALLOc     public_iCALLOc\n" +
   3755 "#define iCOMALLOc   public_iCOMALLOc\n" +
   3756 "#endif\n" +
   3757 "\n" +
   3758 "#ifdef USE_DL_PREFIX\n" +
   3759 "#define public_cALLOc    main_thread_calloc\n" +
   3760 "#define public_fREe      main_thread_free\n" +
   3761 "#define public_cFREe     main_thread_cfree\n" +
   3762 "#define public_mALLOc    main_thread_malloc\n" +
   3763 "#define public_mEMALIGn  main_thread_memalign\n" +
   3764 "#define public_rEALLOc   main_thread_realloc\n" +
   3765 "#define public_vALLOc    main_thread_valloc\n" +
   3766 "#define public_pVALLOc   main_thread_pvalloc\n" +
   3767 "#define public_mALLINFo  main_thread_mallinfo\n" +
   3768 "#define public_mALLOPt   main_thread_mallopt\n" +
   3769 "#define public_mTRIm     main_thread_malloc_trim\n" +
   3770 "#define public_mSTATs    main_thread_malloc_stats\n" +
   3771 "#define public_mUSABLe   main_thread_malloc_usable_size\n" +
   3772 "#define public_iCALLOc   main_thread_independent_calloc\n" +
   3773 "#define public_iCOMALLOc main_thread_independent_comalloc\n" +
   3774 "#else /* USE_DL_PREFIX */\n" +
   3775 "#define public_cALLOc    calloc\n" +
   3776 "#define public_fREe      free\n" +
   3777 "#define public_cFREe     cfree\n" +
   3778 "#define public_mALLOc    malloc\n" +
   3779 "#define public_mEMALIGn  memalign\n" +
   3780 "#define public_rEALLOc   realloc\n" +
   3781 "#define public_vALLOc    valloc\n" +
   3782 "#define public_pVALLOc   pvalloc\n" +
   3783 "#define public_mALLINFo  mallinfo\n" +
   3784 "#define public_mALLOPt   mallopt\n" +
   3785 "#define public_mTRIm     malloc_trim\n" +
   3786 "#define public_mSTATs    malloc_stats\n" +
   3787 "#define public_mUSABLe   malloc_usable_size\n" +
   3788 "#define public_iCALLOc   independent_calloc\n" +
   3789 "#define public_iCOMALLOc independent_comalloc\n" +
   3790 "#endif /* USE_DL_PREFIX */\n" +
   3791 "\n" +
   3792 "\n" +
   3793 "/*\n" +
   3794 "  HAVE_MEMCPY should be defined if you are not otherwise using\n" +
   3795 "  ANSI STD C, but still have memcpy and memset in your C library\n" +
   3796 "  and want to use them in calloc and realloc. Otherwise simple\n" +
   3797 "  macro versions are defined below.\n" +
   3798 "\n") +
   3799 ("  USE_MEMCPY should be defined as 1 if you actually want to\n" +
   3800 "  have memset and memcpy called. People report that the macro\n" +
   3801 "  versions are faster than libc versions on some systems.\n" +
   3802 "\n" +
   3803 "  Even if USE_MEMCPY is set to 1, loops to copy/clear small chunks\n" +
   3804 "  (of <= 36 bytes) are manually unrolled in realloc and calloc.\n" +
   3805 "*/\n" +
   3806 "\n" +
   3807 "#define HAVE_MEMCPY\n" +
   3808 "\n" +
   3809 "#ifndef USE_MEMCPY\n" +
   3810 "#ifdef HAVE_MEMCPY\n" +
   3811 "#define USE_MEMCPY 1\n" +
   3812 "#else\n" +
   3813 "#define USE_MEMCPY 0\n" +
   3814 "#endif\n" +
   3815 "#endif\n" +
   3816 "\n" +
   3817 "\n" +
   3818 "#if (__STD_C || defined(HAVE_MEMCPY))\n" +
   3819 "\n" +
   3820 "#ifdef WIN32\n" +
   3821 "/* On Win32 memset and memcpy are already declared in windows.h */\n" +
   3822 "#else\n" +
   3823 "#if __STD_C\n" +
   3824 "extern \"C\" {\n" +
   3825 "void* memset(void*, int, size_t);\n" +
   3826 "void* memcpy(void*, const void*, size_t);\n" +
   3827 "}\n" +
   3828 "#else\n" +
   3829 "extern \"C\" {\n" +
   3830 "Void_t* memset();\n" +
   3831 "Void_t* memcpy();\n" +
   3832 "}\n" +
   3833 "#endif\n" +
   3834 "#endif\n" +
   3835 "#endif\n" +
   3836 "\n" +
   3837 "/*\n" +
   3838 "  MALLOC_FAILURE_ACTION is the action to take before \"return 0\" when\n" +
   3839 "  malloc fails to be able to return memory, either because memory is\n" +
   3840 "  exhausted or because of illegal arguments.\n" +
   3841 "\n" +
   3842 "  By default, sets errno if running on STD_C platform, else does nothing.\n" +
   3843 "*/\n" +
   3844 "\n" +
   3845 "#ifndef MALLOC_FAILURE_ACTION\n" +
   3846 "#if __STD_C\n" +
   3847 "#define MALLOC_FAILURE_ACTION \\n" +
   3848 "   errno = ENOMEM;\n" +
   3849 "\n" +
   3850 "#else\n" +
   3851 "#define MALLOC_FAILURE_ACTION\n" +
   3852 "#endif\n" +
   3853 "#endif\n" +
   3854 "\n" +
   3855 "/*\n" +
   3856 "  MORECORE-related declarations. By default, rely on sbrk\n" +
   3857 "*/\n" +
   3858 "\n" +
   3859 "\n" +
   3860 "#ifdef LACKS_UNISTD_H\n" +
   3861 "#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)\n" +
   3862 "#if __STD_C\n" +
   3863 "extern Void_t*     sbrk(ptrdiff_t);\n" +
   3864 "#else\n" +
   3865 "extern Void_t*     sbrk();\n" +
   3866 "#endif\n" +
   3867 "#endif\n" +
   3868 "#endif\n" +
   3869 "\n" +
   3870 "/*\n" +
   3871 "  MORECORE is the name of the routine to call to obtain more memory\n" +
   3872 "  from the system.  See below for general guidance on writing\n" +
   3873 "  alternative MORECORE functions, as well as a version for WIN32 and a\n" +
   3874 "  sample version for pre-OSX macos.\n" +
   3875 "*/\n" +
   3876 "\n" +
   3877 "#ifndef MORECORE\n" +
   3878 "#define MORECORE sbrk\n" +
   3879 "#endif\n" +
   3880 "\n" +
   3881 "/*\n" +
   3882 "  MORECORE_FAILURE is the value returned upon failure of MORECORE\n" +
   3883 "  as well as mmap. Since it cannot be an otherwise valid memory address,\n" +
   3884 "  and must reflect values of standard sys calls, you probably ought not\n" +
   3885 "  try to redefine it.\n" +
   3886 "*/\n" +
   3887 "\n" +
   3888 "#ifndef MORECORE_FAILURE\n" +
   3889 "#define MORECORE_FAILURE (-1)\n" +
   3890 "#endif\n" +
   3891 "\n" +
   3892 "/*\n" +
   3893 "  If MORECORE_CONTIGUOUS is true, take advantage of fact that\n" +
   3894 "  consecutive calls to MORECORE with positive arguments always return\n" +
   3895 "  contiguous increasing addresses.  This is true of unix sbrk.  Even\n" +
   3896 "  if not defined, when regions happen to be contiguous, malloc will\n" +
   3897 "  permit allocations spanning regions obtained from different\n" +
   3898 "  calls. But defining this when applicable enables some stronger\n" +
   3899 "  consistency checks and space efficiencies.\n" +
   3900 "*/\n" +
   3901 "\n" +
   3902 "#ifndef MORECORE_CONTIGUOUS\n" +
   3903 "#define MORECORE_CONTIGUOUS 1\n" +
   3904 "#endif\n" +
   3905 "\n" +
   3906 "/*\n" +
   3907 "  Define MORECORE_CANNOT_TRIM if your version of MORECORE\n" +
   3908 "  cannot release space back to the system when given negative\n" +
   3909 "  arguments. This is generally necessary only if you are using\n" +
   3910 "  a hand-crafted MORECORE function that cannot handle negative arguments.\n" +
   3911 "*/\n" +
   3912 "\n" +
   3913 "/* #define MORECORE_CANNOT_TRIM */\n" +
   3914 "\n" +
   3915 "\n" +
   3916 "/*\n" +
   3917 "  Define HAVE_MMAP as true to optionally make malloc() use mmap() to\n" +
   3918 "  allocate very large blocks.  These will be returned to the\n" +
   3919 "  operating system immediately after a free(). Also, if mmap\n" +
   3920 "  is available, it is used as a backup strategy in cases where\n" +
   3921 "  MORECORE fails to provide space from system.\n" +
   3922 "\n" +
   3923 "  This malloc is best tuned to work with mmap for large requests.\n" +
   3924 "  If you do not have mmap, operations involving very large chunks (1MB\n" +
   3925 "  or so) may be slower than you'd like.\n" +
   3926 "*/\n" +
   3927 "\n" +
   3928 "#ifndef HAVE_MMAP\n" +
   3929 "#define HAVE_MMAP 1\n" +
   3930 "#endif\n" +
   3931 "\n" +
   3932 "#if HAVE_MMAP\n" +
   3933 "/*\n" +
   3934 "   Standard unix mmap using /dev/zero clears memory so calloc doesn't\n" +
   3935 "   need to.\n" +
   3936 "*/\n" +
   3937 "\n" +
   3938 "#ifndef MMAP_CLEARS\n" +
   3939 "#define MMAP_CLEARS 1\n" +
   3940 "#endif\n" +
   3941 "\n" +
   3942 "#else /* no mmap */\n" +
   3943 "#ifndef MMAP_CLEARS\n" +
   3944 "#define MMAP_CLEARS 0\n" +
   3945 "#endif\n" +
   3946 "#endif\n" +
   3947 "\n" +
   3948 "\n" +
   3949 "/*\n") +
   3950 ("   MMAP_AS_MORECORE_SIZE is the minimum mmap size argument to use if\n" +
   3951 "   sbrk fails, and mmap is used as a backup (which is done only if\n" +
   3952 "   HAVE_MMAP).  The value must be a multiple of page size.  This\n" +
   3953 "   backup strategy generally applies only when systems have \"holes\" in\n" +
   3954 "   address space, so sbrk cannot perform contiguous expansion, but\n" +
   3955 "   there is still space available on system.  On systems for which\n" +
   3956 "   this is known to be useful (i.e. most linux kernels), this occurs\n" +
   3957 "   only when programs allocate huge amounts of memory.  Between this,\n" +
   3958 "   and the fact that mmap regions tend to be limited, the size should\n" +
   3959 "   be large, to avoid too many mmap calls and thus avoid running out\n" +
   3960 "   of kernel resources.\n" +
   3961 "*/\n" +
   3962 "\n" +
   3963 "#ifndef MMAP_AS_MORECORE_SIZE\n" +
   3964 "#define MMAP_AS_MORECORE_SIZE (1024 * 1024)\n" +
   3965 "#endif\n" +
   3966 "\n" +
   3967 "/*\n" +
   3968 "  Define HAVE_MREMAP to make realloc() use mremap() to re-allocate\n" +
   3969 "  large blocks.  This is currently only possible on Linux with\n" +
   3970 "  kernel versions newer than 1.3.77.\n" +
   3971 "*/\n" +
   3972 "\n" +
   3973 "#ifndef HAVE_MREMAP\n" +
   3974 "#ifdef linux\n" +
   3975 "#define HAVE_MREMAP 1\n" +
   3976 "#else\n" +
   3977 "#define HAVE_MREMAP 0\n" +
   3978 "#endif\n" +
   3979 "\n" +
   3980 "#endif /* HAVE_MMAP */\n" +
   3981 "\n" +
   3982 "\n" +
   3983 "/*\n" +
   3984 "  The system page size. To the extent possible, this malloc manages\n" +
   3985 "  memory from the system in page-size units.  Note that this value is\n" +
   3986 "  cached during initialization into a field of malloc_state. So even\n" +
   3987 "  if malloc_getpagesize is a function, it is only called once.\n" +
   3988 "\n" +
   3989 "  The following mechanics for getpagesize were adapted from bsd/gnu\n" +
   3990 "  getpagesize.h. If none of the system-probes here apply, a value of\n" +
   3991 "  4096 is used, which should be OK: If they don't apply, then using\n" +
   3992 "  the actual value probably doesn't impact performance.\n" +
   3993 "*/\n" +
   3994 "\n" +
   3995 "\n" +
   3996 "#ifndef malloc_getpagesize\n" +
   3997 "\n" +
   3998 "#ifndef LACKS_UNISTD_H\n" +
   3999 "#  include <unistd.h>\n" +
   4000 "#endif\n" +
   4001 "\n" +
   4002 "#  ifdef _SC_PAGESIZE         /* some SVR4 systems omit an underscore */\n" +
   4003 "#    ifndef _SC_PAGE_SIZE\n" +
   4004 "#      define _SC_PAGE_SIZE _SC_PAGESIZE\n" +
   4005 "#    endif\n" +
   4006 "#  endif\n" +
   4007 "\n" +
   4008 "#  ifdef _SC_PAGE_SIZE\n" +
   4009 "#    define malloc_getpagesize sysconf(_SC_PAGE_SIZE)\n" +
   4010 "#  else\n" +
   4011 "#    if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)\n" +
   4012 "       extern size_t getpagesize();\n" +
   4013 "#      define malloc_getpagesize getpagesize()\n" +
   4014 "#    else\n" +
   4015 "#      ifdef WIN32 /* use supplied emulation of getpagesize */\n" +
   4016 "#        define malloc_getpagesize getpagesize()\n" +
   4017 "#      else\n" +
   4018 "#        ifndef LACKS_SYS_PARAM_H\n" +
   4019 "#          include <sys/param.h>\n" +
   4020 "#        endif\n" +
   4021 "#        ifdef EXEC_PAGESIZE\n" +
   4022 "#          define malloc_getpagesize EXEC_PAGESIZE\n" +
   4023 "#        else\n" +
   4024 "#          ifdef NBPG\n" +
   4025 "#            ifndef CLSIZE\n" +
   4026 "#              define malloc_getpagesize NBPG\n" +
   4027 "#            else\n" +
   4028 "#              define malloc_getpagesize (NBPG * CLSIZE)\n" +
   4029 "#            endif\n" +
   4030 "#          else\n" +
   4031 "#            ifdef NBPC\n" +
   4032 "#              define malloc_getpagesize NBPC\n" +
   4033 "#            else\n" +
   4034 "#              ifdef PAGESIZE\n" +
   4035 "#                define malloc_getpagesize PAGESIZE\n" +
   4036 "#              else /* just guess */\n" +
   4037 "#                define malloc_getpagesize (4096)\n" +
   4038 "#              endif\n" +
   4039 "#            endif\n" +
   4040 "#          endif\n" +
   4041 "#        endif\n" +
   4042 "#      endif\n" +
   4043 "#    endif\n" +
   4044 "#  endif\n" +
   4045 "#endif\n" +
   4046 "\n" +
   4047 "/*\n" +
   4048 "  This version of malloc supports the standard SVID/XPG mallinfo\n" +
   4049 "  routine that returns a struct containing usage properties and\n" +
   4050 "  statistics. It should work on any SVID/XPG compliant system that has\n" +
   4051 "  a /usr/include/malloc.h defining struct mallinfo. (If you'd like to\n" +
   4052 "  install such a thing yourself, cut out the preliminary declarations\n" +
   4053 "  as described above and below and save them in a malloc.h file. But\n" +
   4054 "  there's no compelling reason to bother to do this.)\n" +
   4055 "\n" +
   4056 "  The main declaration needed is the mallinfo struct that is returned\n" +
   4057 "  (by-copy) by mallinfo().  The SVID/XPG malloinfo struct contains a\n" +
   4058 "  bunch of fields that are not even meaningful in this version of\n" +
   4059 "  malloc.  These fields are are instead filled by mallinfo() with\n" +
   4060 "  other numbers that might be of interest.\n" +
   4061 "\n" +
   4062 "  HAVE_USR_INCLUDE_MALLOC_H should be set if you have a\n" +
   4063 "  /usr/include/malloc.h file that includes a declaration of struct\n" +
   4064 "  mallinfo.  If so, it is included; else an SVID2/XPG2 compliant\n" +
   4065 "  version is declared below.  These must be precisely the same for\n" +
   4066 "  mallinfo() to work.  The original SVID version of this struct,\n" +
   4067 "  defined on most systems with mallinfo, declares all fields as\n" +
   4068 "  ints. But some others define as unsigned long. If your system\n" +
   4069 "  defines the fields using a type of different width than listed here,\n" +
   4070 "  you must #include your system version and #define\n" +
   4071 "  HAVE_USR_INCLUDE_MALLOC_H.\n" +
   4072 "*/\n" +
   4073 "\n" +
   4074 "/* #define HAVE_USR_INCLUDE_MALLOC_H */\n" +
   4075 "\n" +
   4076 "#ifdef HAVE_USR_INCLUDE_MALLOC_H\n" +
   4077 "#include \"/usr/include/malloc.h\"\n" +
   4078 "#else\n" +
   4079 "\n" +
   4080 "/* SVID2/XPG mallinfo structure */\n" +
   4081 "\n" +
   4082 "struct mallinfo {\n" +
   4083 "  int arena;    /* non-mmapped space allocated from system */\n" +
   4084 "  int ordblks;  /* number of free chunks */\n" +
   4085 "  int smblks;   /* number of fastbin blocks */\n" +
   4086 "  int hblks;    /* number of mmapped regions */\n" +
   4087 "  int hblkhd;   /* space in mmapped regions */\n" +
   4088 "  int usmblks;  /* maximum total allocated space */\n" +
   4089 "  int fsmblks;  /* space available in freed fastbin blocks */\n" +
   4090 "  int uordblks; /* total allocated space */\n" +
   4091 "  int fordblks; /* total free space */\n" +
   4092 "  int keepcost; /* top-most, releasable (via malloc_trim) space */\n" +
   4093 "};\n" +
   4094 "\n" +
   4095 "/*\n" +
   4096 "  SVID/XPG defines four standard parameter numbers for mallopt,\n" +
   4097 "  normally defined in malloc.h.  Only one of these (M_MXFAST) is used\n" +
   4098 "  in this malloc. The others (M_NLBLKS, M_GRAIN, M_KEEP) don't apply,\n" +
   4099 "  so setting them has no effect. But this malloc also supports other\n" +
   4100 "  options in mallopt described below.\n" +
   4101 "*/\n") +
   4102 ("#endif\n" +
   4103 "\n" +
   4104 "\n" +
   4105 "/* ---------- description of public routines ------------ */\n" +
   4106 "\n" +
   4107 "/*\n" +
   4108 "  malloc(size_t n)\n" +
   4109 "  Returns a pointer to a newly allocated chunk of at least n bytes, or null\n" +
   4110 "  if no space is available. Additionally, on failure, errno is\n" +
   4111 "  set to ENOMEM on ANSI C systems.\n" +
   4112 "\n" +
   4113 "  If n is zero, malloc returns a minumum-sized chunk. (The minimum\n" +
   4114 "  size is 16 bytes on most 32bit systems, and 24 or 32 bytes on 64bit\n" +
   4115 "  systems.)  On most systems, size_t is an unsigned type, so calls\n" +
   4116 "  with negative arguments are interpreted as requests for huge amounts\n" +
   4117 "  of space, which will often fail. The maximum supported value of n\n" +
   4118 "  differs across systems, but is in all cases less than the maximum\n" +
   4119 "  representable value of a size_t.\n" +
   4120 "*/\n" +
   4121 "#if __STD_C\n" +
   4122 "Void_t*  public_mALLOc(size_t);\n" +
   4123 "#else\n" +
   4124 "Void_t*  public_mALLOc();\n" +
   4125 "#endif\n" +
   4126 "\n" +
   4127 "/*\n" +
   4128 "  free(Void_t* p)\n" +
   4129 "  Releases the chunk of memory pointed to by p, that had been previously\n" +
   4130 "  allocated using malloc or a related routine such as realloc.\n" +
   4131 "  It has no effect if p is null. It can have arbitrary (i.e., bad!)\n" +
   4132 "  effects if p has already been freed.\n" +
   4133 "\n" +
   4134 "  Unless disabled (using mallopt), freeing very large spaces will\n" +
   4135 "  when possible, automatically trigger operations that give\n" +
   4136 "  back unused memory to the system, thus reducing program footprint.\n" +
   4137 "*/\n" +
   4138 "#if __STD_C\n" +
   4139 "void     public_fREe(Void_t*);\n" +
   4140 "#else\n" +
   4141 "void     public_fREe();\n" +
   4142 "#endif\n" +
   4143 "\n" +
   4144 "/*\n" +
   4145 "  calloc(size_t n_elements, size_t element_size);\n" +
   4146 "  Returns a pointer to n_elements * element_size bytes, with all locations\n" +
   4147 "  set to zero.\n" +
   4148 "*/\n" +
   4149 "#if __STD_C\n" +
   4150 "Void_t*  public_cALLOc(size_t, size_t);\n" +
   4151 "#else\n" +
   4152 "Void_t*  public_cALLOc();\n" +
   4153 "#endif\n" +
   4154 "\n" +
   4155 "/*\n" +
   4156 "  realloc(Void_t* p, size_t n)\n" +
   4157 "  Returns a pointer to a chunk of size n that contains the same data\n" +
   4158 "  as does chunk p up to the minimum of (n, p's size) bytes, or null\n" +
   4159 "  if no space is available.\n" +
   4160 "\n" +
   4161 "  The returned pointer may or may not be the same as p. The algorithm\n" +
   4162 "  prefers extending p when possible, otherwise it employs the\n" +
   4163 "  equivalent of a malloc-copy-free sequence.\n" +
   4164 "\n" +
   4165 "  If p is null, realloc is equivalent to malloc.\n" +
   4166 "\n" +
   4167 "  If space is not available, realloc returns null, errno is set (if on\n" +
   4168 "  ANSI) and p is NOT freed.\n" +
   4169 "\n" +
   4170 "  if n is for fewer bytes than already held by p, the newly unused\n" +
   4171 "  space is lopped off and freed if possible.  Unless the #define\n" +
   4172 "  REALLOC_ZERO_BYTES_FREES is set, realloc with a size argument of\n" +
   4173 "  zero (re)allocates a minimum-sized chunk.\n" +
   4174 "\n" +
   4175 "  Large chunks that were internally obtained via mmap will always\n" +
   4176 "  be reallocated using malloc-copy-free sequences unless\n" +
   4177 "  the system supports MREMAP (currently only linux).\n" +
   4178 "\n" +
   4179 "  The old unix realloc convention of allowing the last-free'd chunk\n" +
   4180 "  to be used as an argument to realloc is not supported.\n" +
   4181 "*/\n" +
   4182 "#if __STD_C\n" +
   4183 "Void_t*  public_rEALLOc(Void_t*, size_t);\n" +
   4184 "#else\n" +
   4185 "Void_t*  public_rEALLOc();\n" +
   4186 "#endif\n" +
   4187 "\n" +
   4188 "/*\n" +
   4189 "  memalign(size_t alignment, size_t n);\n" +
   4190 "  Returns a pointer to a newly allocated chunk of n bytes, aligned\n" +
   4191 "  in accord with the alignment argument.\n" +
   4192 "\n" +
   4193 "  The alignment argument should be a power of two. If the argument is\n" +
   4194 "  not a power of two, the nearest greater power is used.\n" +
   4195 "  8-byte alignment is guaranteed by normal malloc calls, so don't\n" +
   4196 "  bother calling memalign with an argument of 8 or less.\n" +
   4197 "\n" +
   4198 "  Overreliance on memalign is a sure way to fragment space.\n" +
   4199 "*/\n" +
   4200 "#if __STD_C\n" +
   4201 "Void_t*  public_mEMALIGn(size_t, size_t);\n" +
   4202 "#else\n" +
   4203 "Void_t*  public_mEMALIGn();\n" +
   4204 "#endif\n" +
   4205 "\n" +
   4206 "/*\n" +
   4207 "  valloc(size_t n);\n" +
   4208 "  Equivalent to memalign(pagesize, n), where pagesize is the page\n" +
   4209 "  size of the system. If the pagesize is unknown, 4096 is used.\n" +
   4210 "*/\n" +
   4211 "#if __STD_C\n" +
   4212 "Void_t*  public_vALLOc(size_t);\n" +
   4213 "#else\n" +
   4214 "Void_t*  public_vALLOc();\n" +
   4215 "#endif\n" +
   4216 "\n" +
   4217 "\n" +
   4218 "\n" +
   4219 "/*\n" +
   4220 "  mallopt(int parameter_number, int parameter_value)\n" +
   4221 "  Sets tunable parameters The format is to provide a\n" +
   4222 "  (parameter-number, parameter-value) pair.  mallopt then sets the\n" +
   4223 "  corresponding parameter to the argument value if it can (i.e., so\n" +
   4224 "  long as the value is meaningful), and returns 1 if successful else\n" +
   4225 "  0.  SVID/XPG/ANSI defines four standard param numbers for mallopt,\n" +
   4226 "  normally defined in malloc.h.  Only one of these (M_MXFAST) is used\n" +
   4227 "  in this malloc. The others (M_NLBLKS, M_GRAIN, M_KEEP) don't apply,\n" +
   4228 "  so setting them has no effect. But this malloc also supports four\n" +
   4229 "  other options in mallopt. See below for details.  Briefly, supported\n" +
   4230 "  parameters are as follows (listed defaults are for \"typical\"\n" +
   4231 "  configurations).\n" +
   4232 "\n" +
   4233 "  Symbol            param #   default    allowed param values\n" +
   4234 "  M_MXFAST          1         64         0-80  (0 disables fastbins)\n" +
   4235 "  M_TRIM_THRESHOLD -1         256*1024   any   (-1U disables trimming)\n" +
   4236 "  M_TOP_PAD        -2         0          any\n" +
   4237 "  M_MMAP_THRESHOLD -3         256*1024   any   (or 0 if no MMAP support)\n" +
   4238 "  M_MMAP_MAX       -4         65536      any   (0 disables use of mmap)\n" +
   4239 "*/\n" +
   4240 "#if __STD_C\n" +
   4241 "int      public_mALLOPt(int, int);\n" +
   4242 "#else\n" +
   4243 "int      public_mALLOPt();\n" +
   4244 "#endif\n" +
   4245 "\n" +
   4246 "\n" +
   4247 "/*\n" +
   4248 "  mallinfo()\n" +
   4249 "  Returns (by copy) a struct containing various summary statistics:\n" +
   4250 "\n") +
   4251 ("  arena:     current total non-mmapped bytes allocated from system\n" +
   4252 "  ordblks:   the number of free chunks\n" +
   4253 "  smblks:    the number of fastbin blocks (i.e., small chunks that\n" +
   4254 "               have been freed but not use resused or consolidated)\n" +
   4255 "  hblks:     current number of mmapped regions\n" +
   4256 "  hblkhd:    total bytes held in mmapped regions\n" +
   4257 "  usmblks:   the maximum total allocated space. This will be greater\n" +
   4258 "                than current total if trimming has occurred.\n" +
   4259 "  fsmblks:   total bytes held in fastbin blocks\n" +
   4260 "  uordblks:  current total allocated space (normal or mmapped)\n" +
   4261 "  fordblks:  total free space\n" +
   4262 "  keepcost:  the maximum number of bytes that could ideally be released\n" +
   4263 "               back to system via malloc_trim. (\"ideally\" means that\n" +
   4264 "               it ignores page restrictions etc.)\n" +
   4265 "\n" +
   4266 "  Because these fields are ints, but internal bookkeeping may\n" +
   4267 "  be kept as longs, the reported values may wrap around zero and\n" +
   4268 "  thus be inaccurate.\n" +
   4269 "*/\n" +
   4270 "#if __STD_C\n" +
   4271 "struct mallinfo public_mALLINFo(void);\n" +
   4272 "#else\n" +
   4273 "struct mallinfo public_mALLINFo();\n" +
   4274 "#endif\n" +
   4275 "\n" +
   4276 "/*\n" +
   4277 "  independent_calloc(size_t n_elements, size_t element_size, Void_t* chunks[]);\n" +
   4278 "\n" +
   4279 "  independent_calloc is similar to calloc, but instead of returning a\n" +
   4280 "  single cleared space, it returns an array of pointers to n_elements\n" +
   4281 "  independent elements that can hold contents of size elem_size, each\n" +
   4282 "  of which starts out cleared, and can be independently freed,\n" +
   4283 "  realloc'ed etc. The elements are guaranteed to be adjacently\n" +
   4284 "  allocated (this is not guaranteed to occur with multiple callocs or\n" +
   4285 "  mallocs), which may also improve cache locality in some\n" +
   4286 "  applications.\n" +
   4287 "\n" +
   4288 "  The \"chunks\" argument is optional (i.e., may be null, which is\n" +
   4289 "  probably the most typical usage). If it is null, the returned array\n" +
   4290 "  is itself dynamically allocated and should also be freed when it is\n" +
   4291 "  no longer needed. Otherwise, the chunks array must be of at least\n" +
   4292 "  n_elements in length. It is filled in with the pointers to the\n" +
   4293 "  chunks.\n" +
   4294 "\n" +
   4295 "  In either case, independent_calloc returns this pointer array, or\n" +
   4296 "  null if the allocation failed.  If n_elements is zero and \"chunks\"\n" +
   4297 "  is null, it returns a chunk representing an array with zero elements\n" +
   4298 "  (which should be freed if not wanted).\n" +
   4299 "\n" +
   4300 "  Each element must be individually freed when it is no longer\n" +
   4301 "  needed. If you'd like to instead be able to free all at once, you\n" +
   4302 "  should instead use regular calloc and assign pointers into this\n" +
   4303 "  space to represent elements.  (In this case though, you cannot\n" +
   4304 "  independently free elements.)\n" +
   4305 "\n" +
   4306 "  independent_calloc simplifies and speeds up implementations of many\n" +
   4307 "  kinds of pools.  It may also be useful when constructing large data\n" +
   4308 "  structures that initially have a fixed number of fixed-sized nodes,\n" +
   4309 "  but the number is not known at compile time, and some of the nodes\n" +
   4310 "  may later need to be freed. For example:\n" +
   4311 "\n" +
   4312 "  struct Node { int item; struct Node* next; };\n" +
   4313 "\n" +
   4314 "  struct Node* build_list() {\n" +
   4315 "    struct Node** pool;\n" +
   4316 "    int n = read_number_of_nodes_needed();\n" +
   4317 "    if (n <= 0) return 0;\n" +
   4318 "    pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);\n" +
   4319 "    if (pool == 0) die();\n" +
   4320 "    // organize into a linked list...\n" +
   4321 "    struct Node* first = pool[0];\n" +
   4322 "    for (i = 0; i < n-1; ++i)\n" +
   4323 "      pool[i]->next = pool[i+1];\n" +
   4324 "    free(pool);     // Can now free the array (or not, if it is needed later)\n" +
   4325 "    return first;\n" +
   4326 "  }\n" +
   4327 "*/\n" +
   4328 "#if __STD_C\n" +
   4329 "Void_t** public_iCALLOc(size_t, size_t, Void_t**);\n" +
   4330 "#else\n" +
   4331 "Void_t** public_iCALLOc();\n" +
   4332 "#endif\n" +
   4333 "\n" +
   4334 "/*\n" +
   4335 "  independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]);\n" +
   4336 "\n" +
   4337 "  independent_comalloc allocates, all at once, a set of n_elements\n" +
   4338 "  chunks with sizes indicated in the \"sizes\" array.    It returns\n" +
   4339 "  an array of pointers to these elements, each of which can be\n" +
   4340 "  independently freed, realloc'ed etc. The elements are guaranteed to\n" +
   4341 "  be adjacently allocated (this is not guaranteed to occur with\n" +
   4342 "  multiple callocs or mallocs), which may also improve cache locality\n" +
   4343 "  in some applications.\n" +
   4344 "\n" +
   4345 "  The \"chunks\" argument is optional (i.e., may be null). If it is null\n" +
   4346 "  the returned array is itself dynamically allocated and should also\n" +
   4347 "  be freed when it is no longer needed. Otherwise, the chunks array\n" +
   4348 "  must be of at least n_elements in length. It is filled in with the\n" +
   4349 "  pointers to the chunks.\n" +
   4350 "\n" +
   4351 "  In either case, independent_comalloc returns this pointer array, or\n" +
   4352 "  null if the allocation failed.  If n_elements is zero and chunks is\n" +
   4353 "  null, it returns a chunk representing an array with zero elements\n" +
   4354 "  (which should be freed if not wanted).\n" +
   4355 "\n" +
   4356 "  Each element must be individually freed when it is no longer\n" +
   4357 "  needed. If you'd like to instead be able to free all at once, you\n" +
   4358 "  should instead use a single regular malloc, and assign pointers at\n" +
   4359 "  particular offsets in the aggregate space. (In this case though, you\n" +
   4360 "  cannot independently free elements.)\n" +
   4361 "\n" +
   4362 "  independent_comallac differs from independent_calloc in that each\n" +
   4363 "  element may have a different size, and also that it does not\n" +
   4364 "  automatically clear elements.\n" +
   4365 "\n" +
   4366 "  independent_comalloc can be used to speed up allocation in cases\n" +
   4367 "  where several structs or objects must always be allocated at the\n" +
   4368 "  same time.  For example:\n" +
   4369 "\n" +
   4370 "  struct Head { ... }\n" +
   4371 "  struct Foot { ... }\n" +
   4372 "\n" +
   4373 "  void send_message(char* msg) {\n" +
   4374 "    int msglen = strlen(msg);\n" +
   4375 "    size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };\n" +
   4376 "    void* chunks[3];\n" +
   4377 "    if (independent_comalloc(3, sizes, chunks) == 0)\n" +
   4378 "      die();\n" +
   4379 "    struct Head* head = (struct Head*)(chunks[0]);\n" +
   4380 "    char*        body = (char*)(chunks[1]);\n" +
   4381 "    struct Foot* foot = (struct Foot*)(chunks[2]);\n" +
   4382 "    // ...\n" +
   4383 "  }\n" +
   4384 "\n" +
   4385 "  In general though, independent_comalloc is worth using only for\n" +
   4386 "  larger values of n_elements. For small values, you probably won't\n" +
   4387 "  detect enough difference from series of malloc calls to bother.\n" +
   4388 "\n" +
   4389 "  Overuse of independent_comalloc can increase overall memory usage,\n" +
   4390 "  since it cannot reuse existing noncontiguous small chunks that\n" +
   4391 "  might be available for some of the elements.\n" +
   4392 "*/\n" +
   4393 "#if __STD_C\n" +
   4394 "Void_t** public_iCOMALLOc(size_t, size_t*, Void_t**);\n" +
   4395 "#else\n" +
   4396 "Void_t** public_iCOMALLOc();\n" +
   4397 "#endif\n" +
   4398 "\n" +
   4399 "\n" +
   4400 "/*\n") +
   4401 ("  pvalloc(size_t n);\n" +
   4402 "  Equivalent to valloc(minimum-page-that-holds(n)), that is,\n" +
   4403 "  round up n to nearest pagesize.\n" +
   4404 " */\n" +
   4405 "#if __STD_C\n" +
   4406 "Void_t*  public_pVALLOc(size_t);\n" +
   4407 "#else\n" +
   4408 "Void_t*  public_pVALLOc();\n" +
   4409 "#endif\n" +
   4410 "\n" +
   4411 "/*\n" +
   4412 "  cfree(Void_t* p);\n" +
   4413 "  Equivalent to free(p).\n" +
   4414 "\n" +
   4415 "  cfree is needed/defined on some systems that pair it with calloc,\n" +
   4416 "  for odd historical reasons (such as: cfree is used in example\n" +
   4417 "  code in the first edition of K&R).\n" +
   4418 "*/\n" +
   4419 "#if __STD_C\n" +
   4420 "void     public_cFREe(Void_t*);\n" +
   4421 "#else\n" +
   4422 "void     public_cFREe();\n" +
   4423 "#endif\n" +
   4424 "\n" +
   4425 "/*\n" +
   4426 "  malloc_trim(size_t pad);\n" +
   4427 "\n" +
   4428 "  If possible, gives memory back to the system (via negative\n" +
   4429 "  arguments to sbrk) if there is unused memory at the `high' end of\n" +
   4430 "  the malloc pool. You can call this after freeing large blocks of\n" +
   4431 "  memory to potentially reduce the system-level memory requirements\n" +
   4432 "  of a program. However, it cannot guarantee to reduce memory. Under\n" +
   4433 "  some allocation patterns, some large free blocks of memory will be\n" +
   4434 "  locked between two used chunks, so they cannot be given back to\n" +
   4435 "  the system.\n" +
   4436 "\n" +
   4437 "  The `pad' argument to malloc_trim represents the amount of free\n" +
   4438 "  trailing space to leave untrimmed. If this argument is zero,\n" +
   4439 "  only the minimum amount of memory to maintain internal data\n" +
   4440 "  structures will be left (one page or less). Non-zero arguments\n" +
   4441 "  can be supplied to maintain enough trailing space to service\n" +
   4442 "  future expected allocations without having to re-obtain memory\n" +
   4443 "  from the system.\n" +
   4444 "\n" +
   4445 "  Malloc_trim returns 1 if it actually released any memory, else 0.\n" +
   4446 "  On systems that do not support \"negative sbrks\", it will always\n" +
   4447 "  rreturn 0.\n" +
   4448 "*/\n" +
   4449 "#if __STD_C\n" +
   4450 "int      public_mTRIm(size_t);\n" +
   4451 "#else\n" +
   4452 "int      public_mTRIm();\n" +
   4453 "#endif\n" +
   4454 "\n" +
   4455 "/*\n" +
   4456 "  malloc_usable_size(Void_t* p);\n" +
   4457 "\n" +
   4458 "  Returns the number of bytes you can actually use in\n" +
   4459 "  an allocated chunk, which may be more than you requested (although\n" +
   4460 "  often not) due to alignment and minimum size constraints.\n" +
   4461 "  You can use this many bytes without worrying about\n" +
   4462 "  overwriting other allocated objects. This is not a particularly great\n" +
   4463 "  programming practice. malloc_usable_size can be more useful in\n" +
   4464 "  debugging and assertions, for example:\n" +
   4465 "\n" +
   4466 "  p = malloc(n);\n" +
   4467 "  assert(malloc_usable_size(p) >= 256);\n" +
   4468 "\n" +
   4469 "*/\n" +
   4470 "#if __STD_C\n" +
   4471 "size_t   public_mUSABLe(Void_t*);\n" +
   4472 "#else\n" +
   4473 "size_t   public_mUSABLe();\n" +
   4474 "#endif\n" +
   4475 "\n" +
   4476 "/*\n" +
   4477 "  malloc_stats();\n" +
   4478 "  Prints on stderr the amount of space obtained from the system (both\n" +
   4479 "  via sbrk and mmap), the maximum amount (which may be more than\n" +
   4480 "  current if malloc_trim and/or munmap got called), and the current\n" +
   4481 "  number of bytes allocated via malloc (or realloc, etc) but not yet\n" +
   4482 "  freed. Note that this is the number of bytes allocated, not the\n" +
   4483 "  number requested. It will be larger than the number requested\n" +
   4484 "  because of alignment and bookkeeping overhead. Because it includes\n" +
   4485 "  alignment wastage as being in use, this figure may be greater than\n" +
   4486 "  zero even when no user-level chunks are allocated.\n" +
   4487 "\n" +
   4488 "  The reported current and maximum system memory can be inaccurate if\n" +
   4489 "  a program makes other calls to system memory allocation functions\n" +
   4490 "  (normally sbrk) outside of malloc.\n" +
   4491 "\n" +
   4492 "  malloc_stats prints only the most commonly interesting statistics.\n" +
   4493 "  More information can be obtained by calling mallinfo.\n" +
   4494 "\n" +
   4495 "*/\n" +
   4496 "#if __STD_C\n" +
   4497 "void     public_mSTATs();\n" +
   4498 "#else\n" +
   4499 "void     public_mSTATs();\n" +
   4500 "#endif\n" +
   4501 "\n" +
   4502 "/* mallopt tuning options */\n" +
   4503 "\n" +
   4504 "/*\n" +
   4505 "  M_MXFAST is the maximum request size used for \"fastbins\", special bins\n" +
   4506 "  that hold returned chunks without consolidating their spaces. This\n" +
   4507 "  enables future requests for chunks of the same size to be handled\n" +
   4508 "  very quickly, but can increase fragmentation, and thus increase the\n" +
   4509 "  overall memory footprint of a program.\n" +
   4510 "\n" +
   4511 "  This malloc manages fastbins very conservatively yet still\n" +
   4512 "  efficiently, so fragmentation is rarely a problem for values less\n" +
   4513 "  than or equal to the default.  The maximum supported value of MXFAST\n" +
   4514 "  is 80. You wouldn't want it any higher than this anyway.  Fastbins\n" +
   4515 "  are designed especially for use with many small structs, objects or\n" +
   4516 "  strings -- the default handles structs/objects/arrays with sizes up\n" +
   4517 "  to 16 4byte fields, or small strings representing words, tokens,\n" +
   4518 "  etc. Using fastbins for larger objects normally worsens\n" +
   4519 "  fragmentation without improving speed.\n" +
   4520 "\n" +
   4521 "  M_MXFAST is set in REQUEST size units. It is internally used in\n" +
   4522 "  chunksize units, which adds padding and alignment.  You can reduce\n" +
   4523 "  M_MXFAST to 0 to disable all use of fastbins.  This causes the malloc\n" +
   4524 "  algorithm to be a closer approximation of fifo-best-fit in all cases,\n" +
   4525 "  not just for larger requests, but will generally cause it to be\n" +
   4526 "  slower.\n" +
   4527 "*/\n" +
   4528 "\n" +
   4529 "\n" +
   4530 "/* M_MXFAST is a standard SVID/XPG tuning option, usually listed in malloc.h */\n" +
   4531 "#ifndef M_MXFAST\n" +
   4532 "#define M_MXFAST            1\n" +
   4533 "#endif\n" +
   4534 "\n" +
   4535 "#ifndef DEFAULT_MXFAST\n" +
   4536 "#define DEFAULT_MXFAST     64\n" +
   4537 "#endif\n" +
   4538 "\n" +
   4539 "\n" +
   4540 "/*\n" +
   4541 "  M_TRIM_THRESHOLD is the maximum amount of unused top-most memory\n" +
   4542 "  to keep before releasing via malloc_trim in free().\n" +
   4543 "\n" +
   4544 "  Automatic trimming is mainly useful in long-lived programs.\n" +
   4545 "  Because trimming via sbrk can be slow on some systems, and can\n" +
   4546 "  sometimes be wasteful (in cases where programs immediately\n" +
   4547 "  afterward allocate more large chunks) the value should be high\n" +
   4548 "  enough so that your overall system performance would improve by\n" +
   4549 "  releasing this much memory.\n" +
   4550 "\n") +
   4551 ("  The trim threshold and the mmap control parameters (see below)\n" +
   4552 "  can be traded off with one another. Trimming and mmapping are\n" +
   4553 "  two different ways of releasing unused memory back to the\n" +
   4554 "  system. Between these two, it is often possible to keep\n" +
   4555 "  system-level demands of a long-lived program down to a bare\n" +
   4556 "  minimum. For example, in one test suite of sessions measuring\n" +
   4557 "  the XF86 X server on Linux, using a trim threshold of 128K and a\n" +
   4558 "  mmap threshold of 192K led to near-minimal long term resource\n" +
   4559 "  consumption.\n" +
   4560 "\n" +
   4561 "  If you are using this malloc in a long-lived program, it should\n" +
   4562 "  pay to experiment with these values.  As a rough guide, you\n" +
   4563 "  might set to a value close to the average size of a process\n" +
   4564 "  (program) running on your system.  Releasing this much memory\n" +
   4565 "  would allow such a process to run in memory.  Generally, it's\n" +
   4566 "  worth it to tune for trimming rather tham memory mapping when a\n" +
   4567 "  program undergoes phases where several large chunks are\n" +
   4568 "  allocated and released in ways that can reuse each other's\n" +
   4569 "  storage, perhaps mixed with phases where there are no such\n" +
   4570 "  chunks at all.  And in well-behaved long-lived programs,\n" +
   4571 "  controlling release of large blocks via trimming versus mapping\n" +
   4572 "  is usually faster.\n" +
   4573 "\n" +
   4574 "  However, in most programs, these parameters serve mainly as\n" +
   4575 "  protection against the system-level effects of carrying around\n" +
   4576 "  massive amounts of unneeded memory. Since frequent calls to\n" +
   4577 "  sbrk, mmap, and munmap otherwise degrade performance, the default\n" +
   4578 "  parameters are set to relatively high values that serve only as\n" +
   4579 "  safeguards.\n" +
   4580 "\n" +
   4581 "  The trim value must be greater than page size to have any useful\n" +
   4582 "  effect.  To disable trimming completely, you can set to\n" +
   4583 "  (unsigned long)(-1)\n" +
   4584 "\n" +
   4585 "  Trim settings interact with fastbin (MXFAST) settings: Unless\n" +
   4586 "  TRIM_FASTBINS is defined, automatic trimming never takes place upon\n" +
   4587 "  freeing a chunk with size less than or equal to MXFAST. Trimming is\n" +
   4588 "  instead delayed until subsequent freeing of larger chunks. However,\n" +
   4589 "  you can still force an attempted trim by calling malloc_trim.\n" +
   4590 "\n" +
   4591 "  Also, trimming is not generally possible in cases where\n" +
   4592 "  the main arena is obtained via mmap.\n" +
   4593 "\n" +
   4594 "  Note that the trick some people use of mallocing a huge space and\n" +
   4595 "  then freeing it at program startup, in an attempt to reserve system\n" +
   4596 "  memory, doesn't have the intended effect under automatic trimming,\n" +
   4597 "  since that memory will immediately be returned to the system.\n" +
   4598 "*/\n" +
   4599 "\n" +
   4600 "#define M_TRIM_THRESHOLD       -1\n" +
   4601 "\n" +
   4602 "#ifndef DEFAULT_TRIM_THRESHOLD\n" +
   4603 "#define DEFAULT_TRIM_THRESHOLD (256 * 1024)\n" +
   4604 "#endif\n" +
   4605 "\n" +
   4606 "/*\n" +
   4607 "  M_TOP_PAD is the amount of extra `padding' space to allocate or\n" +
   4608 "  retain whenever sbrk is called. It is used in two ways internally:\n" +
   4609 "\n" +
   4610 "  * When sbrk is called to extend the top of the arena to satisfy\n" +
   4611 "  a new malloc request, this much padding is added to the sbrk\n" +
   4612 "  request.\n" +
   4613 "\n" +
   4614 "  * When malloc_trim is called automatically from free(),\n" +
   4615 "  it is used as the `pad' argument.\n" +
   4616 "\n" +
   4617 "  In both cases, the actual amount of padding is rounded\n" +
   4618 "  so that the end of the arena is always a system page boundary.\n" +
   4619 "\n" +
   4620 "  The main reason for using padding is to avoid calling sbrk so\n" +
   4621 "  often. Having even a small pad greatly reduces the likelihood\n" +
   4622 "  that nearly every malloc request during program start-up (or\n" +
   4623 "  after trimming) will invoke sbrk, which needlessly wastes\n" +
   4624 "  time.\n" +
   4625 "\n" +
   4626 "  Automatic rounding-up to page-size units is normally sufficient\n" +
   4627 "  to avoid measurable overhead, so the default is 0.  However, in\n" +
   4628 "  systems where sbrk is relatively slow, it can pay to increase\n" +
   4629 "  this value, at the expense of carrying around more memory than\n" +
   4630 "  the program needs.\n" +
   4631 "*/\n" +
   4632 "\n" +
   4633 "#define M_TOP_PAD              -2\n" +
   4634 "\n" +
   4635 "#ifndef DEFAULT_TOP_PAD\n" +
   4636 "#define DEFAULT_TOP_PAD        (0)\n" +
   4637 "#endif\n" +
   4638 "\n" +
   4639 "/*\n" +
   4640 "  M_MMAP_THRESHOLD is the request size threshold for using mmap()\n" +
   4641 "  to service a request. Requests of at least this size that cannot\n" +
   4642 "  be allocated using already-existing space will be serviced via mmap.\n" +
   4643 "  (If enough normal freed space already exists it is used instead.)\n" +
   4644 "\n" +
   4645 "  Using mmap segregates relatively large chunks of memory so that\n" +
   4646 "  they can be individually obtained and released from the host\n" +
   4647 "  system. A request serviced through mmap is never reused by any\n" +
   4648 "  other request (at least not directly; the system may just so\n" +
   4649 "  happen to remap successive requests to the same locations).\n" +
   4650 "\n" +
   4651 "  Segregating space in this way has the benefits that:\n" +
   4652 "\n" +
   4653 "   1. Mmapped space can ALWAYS be individually released back\n" +
   4654 "      to the system, which helps keep the system level memory\n" +
   4655 "      demands of a long-lived program low.\n" +
   4656 "   2. Mapped memory can never become `locked' between\n" +
   4657 "      other chunks, as can happen with normally allocated chunks, which\n" +
   4658 "      means that even trimming via malloc_trim would not release them.\n" +
   4659 "   3. On some systems with \"holes\" in address spaces, mmap can obtain\n" +
   4660 "      memory that sbrk cannot.\n" +
   4661 "\n" +
   4662 "  However, it has the disadvantages that:\n" +
   4663 "\n" +
   4664 "   1. The space cannot be reclaimed, consolidated, and then\n" +
   4665 "      used to service later requests, as happens with normal chunks.\n" +
   4666 "   2. It can lead to more wastage because of mmap page alignment\n" +
   4667 "      requirements\n" +
   4668 "   3. It causes malloc performance to be more dependent on host\n" +
   4669 "      system memory management support routines which may vary in\n" +
   4670 "      implementation quality and may impose arbitrary\n" +
   4671 "      limitations. Generally, servicing a request via normal\n" +
   4672 "      malloc steps is faster than going through a system's mmap.\n" +
   4673 "\n" +
   4674 "  The advantages of mmap nearly always outweigh disadvantages for\n" +
   4675 "  \"large\" chunks, but the value of \"large\" varies across systems.  The\n" +
   4676 "  default is an empirically derived value that works well in most\n" +
   4677 "  systems.\n" +
   4678 "*/\n" +
   4679 "\n" +
   4680 "#define M_MMAP_THRESHOLD      -3\n" +
   4681 "\n" +
   4682 "#ifndef DEFAULT_MMAP_THRESHOLD\n" +
   4683 "#define DEFAULT_MMAP_THRESHOLD (256 * 1024)\n" +
   4684 "#endif\n" +
   4685 "\n" +
   4686 "/*\n" +
   4687 "  M_MMAP_MAX is the maximum number of requests to simultaneously\n" +
   4688 "  service using mmap. This parameter exists because\n" +
   4689 ". Some systems have a limited number of internal tables for\n" +
   4690 "  use by mmap, and using more than a few of them may degrade\n" +
   4691 "  performance.\n" +
   4692 "\n" +
   4693 "  The default is set to a value that serves only as a safeguard.\n" +
   4694 "  Setting to 0 disables use of mmap for servicing large requests.  If\n" +
   4695 "  HAVE_MMAP is not set, the default value is 0, and attempts to set it\n" +
   4696 "  to non-zero values in mallopt will fail.\n" +
   4697 "*/\n" +
   4698 "\n" +
   4699 "#define M_MMAP_MAX             -4\n" +
   4700 "\n") +
   4701 ("#ifndef DEFAULT_MMAP_MAX\n" +
   4702 "#if HAVE_MMAP\n" +
   4703 "#define DEFAULT_MMAP_MAX       (65536)\n" +
   4704 "#else\n" +
   4705 "#define DEFAULT_MMAP_MAX       (0)\n" +
   4706 "#endif\n" +
   4707 "#endif\n" +
   4708 "\n" +
   4709 "/*\n" +
   4710 "  ========================================================================\n" +
   4711 "  To make a fully customizable malloc.h header file, cut everything\n" +
   4712 "  above this line, put into file malloc.h, edit to suit, and #include it\n" +
   4713 "  on the next line, as well as in programs that use this malloc.\n" +
   4714 "  ========================================================================\n" +
   4715 "*/\n" +
   4716 "\n" +
   4717 "/* #include \"malloc.h\" */\n" +
   4718 "\n" +
   4719 "/* --------------------- public wrappers ---------------------- */\n" +
   4720 "\n" +
   4721 "#ifdef USE_PUBLIC_MALLOC_WRAPPERS\n" +
   4722 "\n" +
   4723 "/* Declare all routines as internal */\n" +
   4724 "#if __STD_C\n" +
   4725 "static Void_t*  mALLOc(size_t);\n" +
   4726 "static void     fREe(Void_t*);\n" +
   4727 "static Void_t*  rEALLOc(Void_t*, size_t);\n" +
   4728 "static Void_t*  mEMALIGn(size_t, size_t);\n" +
   4729 "static Void_t*  vALLOc(size_t);\n" +
   4730 "static Void_t*  pVALLOc(size_t);\n" +
   4731 "static Void_t*  cALLOc(size_t, size_t);\n" +
   4732 "static Void_t** iCALLOc(size_t, size_t, Void_t**);\n" +
   4733 "static Void_t** iCOMALLOc(size_t, size_t*, Void_t**);\n" +
   4734 "static void     cFREe(Void_t*);\n" +
   4735 "static int      mTRIm(size_t);\n" +
   4736 "static size_t   mUSABLe(Void_t*);\n" +
   4737 "static void     mSTATs();\n" +
   4738 "static int      mALLOPt(int, int);\n" +
   4739 "static struct mallinfo mALLINFo(void);\n" +
   4740 "#else\n" +
   4741 "static Void_t*  mALLOc();\n" +
   4742 "static void     fREe();\n" +
   4743 "static Void_t*  rEALLOc();\n" +
   4744 "static Void_t*  mEMALIGn();\n" +
   4745 "static Void_t*  vALLOc();\n" +
   4746 "static Void_t*  pVALLOc();\n" +
   4747 "static Void_t*  cALLOc();\n" +
   4748 "static Void_t** iCALLOc();\n" +
   4749 "static Void_t** iCOMALLOc();\n" +
   4750 "static void     cFREe();\n" +
   4751 "static int      mTRIm();\n" +
   4752 "static size_t   mUSABLe();\n" +
   4753 "static void     mSTATs();\n" +
   4754 "static int      mALLOPt();\n" +
   4755 "static struct mallinfo mALLINFo();\n" +
   4756 "#endif\n" +
   4757 "\n" +
   4758 "/*\n" +
   4759 "  MALLOC_PREACTION and MALLOC_POSTACTION should be\n" +
   4760 "  defined to return 0 on success, and nonzero on failure.\n" +
   4761 "  The return value of MALLOC_POSTACTION is currently ignored\n" +
   4762 "  in wrapper functions since there is no reasonable default\n" +
   4763 "  action to take on failure.\n" +
   4764 "*/\n" +
   4765 "\n" +
   4766 "\n" +
   4767 "#ifdef USE_MALLOC_LOCK\n" +
   4768 "\n" +
   4769 "#ifdef WIN32\n" +
   4770 "\n" +
   4771 "static int mALLOC_MUTEx;\n" +
   4772 "#define MALLOC_PREACTION   slwait(&mALLOC_MUTEx)\n" +
   4773 "#define MALLOC_POSTACTION  slrelease(&mALLOC_MUTEx)\n" +
   4774 "\n" +
   4775 "#else\n" +
   4776 "\n" +
   4777 "#include <pthread.h>\n" +
   4778 "\n" +
   4779 "static pthread_mutex_t mALLOC_MUTEx = PTHREAD_MUTEX_INITIALIZER;\n" +
   4780 "\n" +
   4781 "#define MALLOC_PREACTION   pthread_mutex_lock(&mALLOC_MUTEx)\n" +
   4782 "#define MALLOC_POSTACTION  pthread_mutex_unlock(&mALLOC_MUTEx)\n" +
   4783 "\n" +
   4784 "#endif /* USE_MALLOC_LOCK */\n" +
   4785 "\n" +
   4786 "#else\n" +
   4787 "\n" +
   4788 "/* Substitute anything you like for these */\n" +
   4789 "\n" +
   4790 "#define MALLOC_PREACTION   (0)\n" +
   4791 "#define MALLOC_POSTACTION  (0)\n" +
   4792 "\n" +
   4793 "#endif\n" +
   4794 "\n" +
   4795 "Void_t* public_mALLOc(size_t bytes) {\n" +
   4796 "  Void_t* m;\n" +
   4797 "  if (MALLOC_PREACTION != 0) {\n" +
   4798 "    return 0;\n" +
   4799 "  }\n" +
   4800 "  m = mALLOc(bytes);\n" +
   4801 "  if (MALLOC_POSTACTION != 0) {\n" +
   4802 "  }\n" +
   4803 "  return m;\n" +
   4804 "}\n" +
   4805 "\n" +
   4806 "\n" +
   4807 "static pthread_once_t free_mutex_once = PTHREAD_ONCE_INIT;\n" +
   4808 "static pthread_mutex_t free_mutex;\n" +
   4809 "static int scheduled_free_size;\n" +
   4810 "static int scheduled_free_capacity;\n" +
   4811 "static int scheduled_free_list;\n" +
   4812 "bool free_is_scheduled;\n" +
   4813 "\n" +
   4814 "static void initialize_scheduled_free_list()\n" +
   4815 "{\n" +
   4816 "    pthread_mutex_init(&free_mutex, NULL);\n" +
   4817 "}\n" +
   4818 "\n" +
   4819 "static void drain_scheduled_free_list()\n" +
   4820 "{\n" +
   4821 "    pthread_mutex_lock(&free_mutex);\n" +
   4822 "    if (free_is_scheduled) {\n" +
   4823 "        for(int i = 0; i < scheduled_free_size; i++) {\n" +
   4824 "            main_thread_free(scheduled_free_list[i]);\n" +
   4825 "        }\n" +
   4826 "        free(scheduled_free_list);\n" +
   4827 "        scheduled_free_list = NULL;\n" +
   4828 "        scheduled_free_size = 0;\n" +
   4829 "        scheduled_free_capacity = 0;\n" +
   4830 "        free_is_scheduled = false;\n" +
   4831 "    }\n" +
   4832 "    pthread_mutex_unlock(&free_mutex);\n" +
   4833 "}\n" +
   4834 "\n" +
   4835 "static void schedule_free_on_main_thread(Void_t* m)\n" +
   4836 "{\n" +
   4837 "    pthread_once(&free_mutex_once, initialize_scheduled_free_list);\n" +
   4838 "\n" +
   4839 "    pthread_mutex_lock(&free_mutex);\n" +
   4840 "    if (scheduled_free_size == scheduled_free_capacity) {\n" +
   4841 "        scheduled_free_capacity = scheduled_free_capacity == 0 ? 16 : scheduled_free_capacity * 1.2;\n" +
   4842 "        scheduled_free_list = (Void_t**)realloc(scheduled_free_list, sizeof(Void_t*) * scheduled_free_capacity);\n" +
   4843 "    }\n" +
   4844 "    scheduled_free_list[scheduled_free_size++] = m;\n" +
   4845 "    if (!free_is_scheduled) {\n" +
   4846 "        QTimer::immediateSingleShotOnMainThread(0, drain_scheduled_free_list);\n" +
   4847 "        free_is_scheduled = true;\n" +
   4848 "    }\n" +
   4849 "    pthread_mutex_unlock(&free_mutex);\n" +
   4850 "}\n") +
   4851 ("\n" +
   4852 "void public_fREe(Void_t* m) {\n" +
   4853 "  if (!pthread_main_np()) {\n" +
   4854 "      schedule_free_on_main_thread(m);\n" +
   4855 "      return;\n" +
   4856 "  }\n" +
   4857 "\n" +
   4858 "  if (MALLOC_PREACTION != 0) {\n" +
   4859 "    return;\n" +
   4860 "  }\n" +
   4861 "  fREe(m);\n" +
   4862 "  if (MALLOC_POSTACTION != 0) {\n" +
   4863 "  }\n" +
   4864 "}\n" +
   4865 "\n" +
   4866 "Void_t* public_rEALLOc(Void_t* m, size_t bytes) {\n" +
   4867 "  if (MALLOC_PREACTION != 0) {\n" +
   4868 "    return 0;\n" +
   4869 "  }\n" +
   4870 "  m = rEALLOc(m, bytes);\n" +
   4871 "  if (MALLOC_POSTACTION != 0) {\n" +
   4872 "  }\n" +
   4873 "  return m;\n" +
   4874 "}\n" +
   4875 "\n" +
   4876 "Void_t* public_mEMALIGn(size_t alignment, size_t bytes) {\n" +
   4877 "  Void_t* m;\n" +
   4878 "  if (MALLOC_PREACTION != 0) {\n" +
   4879 "    return 0;\n" +
   4880 "  }\n" +
   4881 "  m = mEMALIGn(alignment, bytes);\n" +
   4882 "  if (MALLOC_POSTACTION != 0) {\n" +
   4883 "  }\n" +
   4884 "  return m;\n" +
   4885 "}\n" +
   4886 "\n" +
   4887 "Void_t* public_vALLOc(size_t bytes) {\n" +
   4888 "  Void_t* m;\n" +
   4889 "  if (MALLOC_PREACTION != 0) {\n" +
   4890 "    return 0;\n" +
   4891 "  }\n" +
   4892 "  m = vALLOc(bytes);\n" +
   4893 "  if (MALLOC_POSTACTION != 0) {\n" +
   4894 "  }\n" +
   4895 "  return m;\n" +
   4896 "}\n" +
   4897 "\n" +
   4898 "Void_t* public_pVALLOc(size_t bytes) {\n" +
   4899 "  Void_t* m;\n" +
   4900 "  if (MALLOC_PREACTION != 0) {\n" +
   4901 "    return 0;\n" +
   4902 "  }\n" +
   4903 "  m = pVALLOc(bytes);\n" +
   4904 "  if (MALLOC_POSTACTION != 0) {\n" +
   4905 "  }\n" +
   4906 "  return m;\n" +
   4907 "}\n" +
   4908 "\n" +
   4909 "Void_t* public_cALLOc(size_t n, size_t elem_size) {\n" +
   4910 "  Void_t* m;\n" +
   4911 "  if (MALLOC_PREACTION != 0) {\n" +
   4912 "    return 0;\n" +
   4913 "  }\n" +
   4914 "  m = cALLOc(n, elem_size);\n" +
   4915 "  if (MALLOC_POSTACTION != 0) {\n" +
   4916 "  }\n" +
   4917 "  return m;\n" +
   4918 "}\n" +
   4919 "\n" +
   4920 "\n" +
   4921 "Void_t** public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks) {\n" +
   4922 "  Void_t** m;\n" +
   4923 "  if (MALLOC_PREACTION != 0) {\n" +
   4924 "    return 0;\n" +
   4925 "  }\n" +
   4926 "  m = iCALLOc(n, elem_size, chunks);\n" +
   4927 "  if (MALLOC_POSTACTION != 0) {\n" +
   4928 "  }\n" +
   4929 "  return m;\n" +
   4930 "}\n" +
   4931 "\n" +
   4932 "Void_t** public_iCOMALLOc(size_t n, size_t sizes[], Void_t** chunks) {\n" +
   4933 "  Void_t** m;\n" +
   4934 "  if (MALLOC_PREACTION != 0) {\n" +
   4935 "    return 0;\n" +
   4936 "  }\n" +
   4937 "  m = iCOMALLOc(n, sizes, chunks);\n" +
   4938 "  if (MALLOC_POSTACTION != 0) {\n" +
   4939 "  }\n" +
   4940 "  return m;\n" +
   4941 "}\n" +
   4942 "\n" +
   4943 "void public_cFREe(Void_t* m) {\n" +
   4944 "  if (MALLOC_PREACTION != 0) {\n" +
   4945 "    return;\n" +
   4946 "  }\n" +
   4947 "  cFREe(m);\n" +
   4948 "  if (MALLOC_POSTACTION != 0) {\n" +
   4949 "  }\n" +
   4950 "}\n" +
   4951 "\n" +
   4952 "int public_mTRIm(size_t s) {\n" +
   4953 "  int result;\n" +
   4954 "  if (MALLOC_PREACTION != 0) {\n" +
   4955 "    return 0;\n" +
   4956 "  }\n" +
   4957 "  result = mTRIm(s);\n" +
   4958 "  if (MALLOC_POSTACTION != 0) {\n" +
   4959 "  }\n" +
   4960 "  return result;\n" +
   4961 "}\n" +
   4962 "\n" +
   4963 "size_t public_mUSABLe(Void_t* m) {\n" +
   4964 "  size_t result;\n" +
   4965 "  if (MALLOC_PREACTION != 0) {\n" +
   4966 "    return 0;\n" +
   4967 "  }\n" +
   4968 "  result = mUSABLe(m);\n" +
   4969 "  if (MALLOC_POSTACTION != 0) {\n" +
   4970 "  }\n" +
   4971 "  return result;\n" +
   4972 "}\n" +
   4973 "\n" +
   4974 "void public_mSTATs() {\n" +
   4975 "  if (MALLOC_PREACTION != 0) {\n" +
   4976 "    return;\n" +
   4977 "  }\n" +
   4978 "  mSTATs();\n" +
   4979 "  if (MALLOC_POSTACTION != 0) {\n" +
   4980 "  }\n" +
   4981 "}\n" +
   4982 "\n" +
   4983 "struct mallinfo public_mALLINFo() {\n" +
   4984 "  struct mallinfo m;\n" +
   4985 "  if (MALLOC_PREACTION != 0) {\n" +
   4986 "    struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\n" +
   4987 "    return nm;\n" +
   4988 "  }\n" +
   4989 "  m = mALLINFo();\n" +
   4990 "  if (MALLOC_POSTACTION != 0) {\n" +
   4991 "  }\n" +
   4992 "  return m;\n" +
   4993 "}\n" +
   4994 "\n" +
   4995 "int public_mALLOPt(int p, int v) {\n" +
   4996 "  int result;\n" +
   4997 "  if (MALLOC_PREACTION != 0) {\n" +
   4998 "    return 0;\n" +
   4999 "  }\n" +
   5000 "  result = mALLOPt(p, v);\n" +
   5001 "  if (MALLOC_POSTACTION != 0) {\n" +
   5002 "  }\n" +
   5003 "  return result;\n" +
   5004 "}\n" +
   5005 "\n") +
   5006 ("#endif\n" +
   5007 "\n" +
   5008 "\n" +
   5009 "\n" +
   5010 "/* ------------- Optional versions of memcopy ---------------- */\n" +
   5011 "\n" +
   5012 "\n" +
   5013 "#if USE_MEMCPY\n" +
   5014 "\n" +
   5015 "/*\n" +
   5016 "  Note: memcpy is ONLY invoked with non-overlapping regions,\n" +
   5017 "  so the (usually slower) memmove is not needed.\n" +
   5018 "*/\n" +
   5019 "\n" +
   5020 "#define MALLOC_COPY(dest, src, nbytes)  memcpy(dest, src, nbytes)\n" +
   5021 "#define MALLOC_ZERO(dest, nbytes)       memset(dest, 0,   nbytes)\n" +
   5022 "\n" +
   5023 "#else /* !USE_MEMCPY */\n" +
   5024 "\n" +
   5025 "/* Use Duff's device for good zeroing/copying performance. */\n" +
   5026 "\n" +
   5027 "#define MALLOC_ZERO(charp, nbytes)                                            \\n" +
   5028 "do {                                                                          \\n" +
   5029 "  INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp);                           \\n" +
   5030 "  CHUNK_SIZE_T  mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T);                     \\n" +
   5031 "  long mcn;                                                                   \\n" +
   5032 "  if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; }             \\n" +
   5033 "  switch (mctmp) {                                                            \\n" +
   5034 "    case 0: for(;;) { *mzp++ = 0;                                             \\n" +
   5035 "    case 7:           *mzp++ = 0;                                             \\n" +
   5036 "    case 6:           *mzp++ = 0;                                             \\n" +
   5037 "    case 5:           *mzp++ = 0;                                             \\n" +
   5038 "    case 4:           *mzp++ = 0;                                             \\n" +
   5039 "    case 3:           *mzp++ = 0;                                             \\n" +
   5040 "    case 2:           *mzp++ = 0;                                             \\n" +
   5041 "    case 1:           *mzp++ = 0; if(mcn <= 0) break; mcn--; }                \\n" +
   5042 "  }                                                                           \\n" +
   5043 "} while(0)\n" +
   5044 "\n" +
   5045 "#define MALLOC_COPY(dest,src,nbytes)                                          \\n" +
   5046 "do {                                                                          \\n" +
   5047 "  INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src;                            \\n" +
   5048 "  INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest;                           \\n" +
   5049 "  CHUNK_SIZE_T  mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T);                     \\n" +
   5050 "  long mcn;                                                                   \\n" +
   5051 "  if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; }             \\n" +
   5052 "  switch (mctmp) {                                                            \\n" +
   5053 "    case 0: for(;;) { *mcdst++ = *mcsrc++;                                    \\n" +
   5054 "    case 7:           *mcdst++ = *mcsrc++;                                    \\n" +
   5055 "    case 6:           *mcdst++ = *mcsrc++;                                    \\n" +
   5056 "    case 5:           *mcdst++ = *mcsrc++;                                    \\n" +
   5057 "    case 4:           *mcdst++ = *mcsrc++;                                    \\n" +
   5058 "    case 3:           *mcdst++ = *mcsrc++;                                    \\n" +
   5059 "    case 2:           *mcdst++ = *mcsrc++;                                    \\n" +
   5060 "    case 1:           *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; }       \\n" +
   5061 "  }                                                                           \\n" +
   5062 "} while(0)\n" +
   5063 "\n" +
   5064 "#endif\n" +
   5065 "\n" +
   5066 "/* ------------------ MMAP support ------------------  */\n" +
   5067 "\n" +
   5068 "\n" +
   5069 "#if HAVE_MMAP\n" +
   5070 "\n" +
   5071 "#ifndef LACKS_FCNTL_H\n" +
   5072 "#include <fcntl.h>\n" +
   5073 "#endif\n" +
   5074 "\n" +
   5075 "#ifndef LACKS_SYS_MMAN_H\n" +
   5076 "#include <sys/mman.h>\n" +
   5077 "#endif\n" +
   5078 "\n" +
   5079 "#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)\n" +
   5080 "#define MAP_ANONYMOUS MAP_ANON\n" +
   5081 "#endif\n" +
   5082 "\n" +
   5083 "/*\n" +
   5084 "   Nearly all versions of mmap support MAP_ANONYMOUS,\n" +
   5085 "   so the following is unlikely to be needed, but is\n" +
   5086 "   supplied just in case.\n" +
   5087 "*/\n" +
   5088 "\n" +
   5089 "#ifndef MAP_ANONYMOUS\n" +
   5090 "\n" +
   5091 "static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */\n" +
   5092 "\n" +
   5093 "#define MMAP(addr, size, prot, flags) ((dev_zero_fd < 0) ? \\n" +
   5094 " (dev_zero_fd = open(\"/dev/zero\", O_RDWR), \\n" +
   5095 "  mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) : \\n" +
   5096 "   mmap((addr), (size), (prot), (flags), dev_zero_fd, 0))\n" +
   5097 "\n" +
   5098 "#else\n" +
   5099 "\n" +
   5100 "#define MMAP(addr, size, prot, flags) \\n" +
   5101 " (mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS, -1, 0))\n" +
   5102 "\n" +
   5103 "#endif\n" +
   5104 "\n" +
   5105 "\n" +
   5106 "#endif /* HAVE_MMAP */\n" +
   5107 "\n" +
   5108 "\n" +
   5109 "/*\n" +
   5110 "  -----------------------  Chunk representations -----------------------\n" +
   5111 "*/\n" +
   5112 "\n" +
   5113 "\n" +
   5114 "/*\n" +
   5115 "  This struct declaration is misleading (but accurate and necessary).\n" +
   5116 "  It declares a \"view\" into memory allowing access to necessary\n" +
   5117 "  fields at known offsets from a given base. See explanation below.\n" +
   5118 "*/\n" +
   5119 "\n" +
   5120 "struct malloc_chunk {\n" +
   5121 "\n" +
   5122 "  INTERNAL_SIZE_T      prev_size;  /* Size of previous chunk (if free).  */\n" +
   5123 "  INTERNAL_SIZE_T      size;       /* Size in bytes, including overhead. */\n" +
   5124 "\n" +
   5125 "  struct malloc_chunk* fd;         /* double links -- used only if free. */\n" +
   5126 "  struct malloc_chunk* bk;\n" +
   5127 "};\n" +
   5128 "\n" +
   5129 "\n" +
   5130 "typedef struct malloc_chunk* mchunkptr;\n" +
   5131 "\n" +
   5132 "/*\n" +
   5133 "   malloc_chunk details:\n" +
   5134 "\n" +
   5135 "    (The following includes lightly edited explanations by Colin Plumb.)\n" +
   5136 "\n" +
   5137 "    Chunks of memory are maintained using a `boundary tag' method as\n" +
   5138 "    described in e.g., Knuth or Standish.  (See the paper by Paul\n" +
   5139 "    Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a\n" +
   5140 "    survey of such techniques.)  Sizes of free chunks are stored both\n" +
   5141 "    in the front of each chunk and at the end.  This makes\n" +
   5142 "    consolidating fragmented chunks into bigger chunks very fast.  The\n" +
   5143 "    size fields also hold bits representing whether chunks are free or\n" +
   5144 "    in use.\n" +
   5145 "\n" +
   5146 "    An allocated chunk looks like this:\n" +
   5147 "\n" +
   5148 "\n" +
   5149 "    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5150 "            |             Size of previous chunk, if allocated            | |\n" +
   5151 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5152 "            |             Size of chunk, in bytes                         |P|\n" +
   5153 "      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5154 "            |             User data starts here...                          .\n" +
   5155 "            .                                                               .\n" +
   5156 "            .             (malloc_usable_space() bytes)                     .\n" +
   5157 "            .                                                               |\n" +
   5158 "nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5159 "            |             Size of chunk                                     |\n" +
   5160 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5161 "\n") +
   5162 ("\n" +
   5163 "    Where \"chunk\" is the front of the chunk for the purpose of most of\n" +
   5164 "    the malloc code, but \"mem\" is the pointer that is returned to the\n" +
   5165 "    user.  \"Nextchunk\" is the beginning of the next contiguous chunk.\n" +
   5166 "\n" +
   5167 "    Chunks always begin on even word boundries, so the mem portion\n" +
   5168 "    (which is returned to the user) is also on an even word boundary, and\n" +
   5169 "    thus at least double-word aligned.\n" +
   5170 "\n" +
   5171 "    Free chunks are stored in circular doubly-linked lists, and look like this:\n" +
   5172 "\n" +
   5173 "    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5174 "            |             Size of previous chunk                            |\n" +
   5175 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5176 "    `head:' |             Size of chunk, in bytes                         |P|\n" +
   5177 "      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5178 "            |             Forward pointer to next chunk in list             |\n" +
   5179 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5180 "            |             Back pointer to previous chunk in list            |\n" +
   5181 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5182 "            |             Unused space (may be 0 bytes long)                .\n" +
   5183 "            .                                                               .\n" +
   5184 "            .                                                               |\n" +
   5185 "nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5186 "    `foot:' |             Size of chunk, in bytes                           |\n" +
   5187 "            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n" +
   5188 "\n" +
   5189 "    The P (PREV_INUSE) bit, stored in the unused low-order bit of the\n" +
   5190 "    chunk size (which is always a multiple of two words), is an in-use\n" +
   5191 "    bit for the *previous* chunk.  If that bit is *clear*, then the\n" +
   5192 "    word before the current chunk size contains the previous chunk\n" +
   5193 "    size, and can be used to find the front of the previous chunk.\n" +
   5194 "    The very first chunk allocated always has this bit set,\n" +
   5195 "    preventing access to non-existent (or non-owned) memory. If\n" +
   5196 "    prev_inuse is set for any given chunk, then you CANNOT determine\n" +
   5197 "    the size of the previous chunk, and might even get a memory\n" +
   5198 "    addressing fault when trying to do so.\n" +
   5199 "\n" +
   5200 "    Note that the `foot' of the current chunk is actually represented\n" +
   5201 "    as the prev_size of the NEXT chunk. This makes it easier to\n" +
   5202 "    deal with alignments etc but can be very confusing when trying\n" +
   5203 "    to extend or adapt this code.\n" +
   5204 "\n" +
   5205 "    The two exceptions to all this are\n" +
   5206 "\n" +
   5207 "     1. The special chunk `top' doesn't bother using the\n" +
   5208 "        trailing size field since there is no next contiguous chunk\n" +
   5209 "        that would have to index off it. After initialization, `top'\n" +
   5210 "        is forced to always exist.  If it would become less than\n" +
   5211 "        MINSIZE bytes long, it is replenished.\n" +
   5212 "\n" +
   5213 "     2. Chunks allocated via mmap, which have the second-lowest-order\n" +
   5214 "        bit (IS_MMAPPED) set in their size fields.  Because they are\n" +
   5215 "        allocated one-by-one, each must contain its own trailing size field.\n" +
   5216 "\n" +
   5217 "*/\n" +
   5218 "\n" +
   5219 "/*\n" +
   5220 "  ---------- Size and alignment checks and conversions ----------\n" +
   5221 "*/\n" +
   5222 "\n" +
   5223 "/* conversion from malloc headers to user pointers, and back */\n" +
   5224 "\n" +
   5225 "#define chunk2mem(p)   ((Void_t*)((char*)(p) + 2*SIZE_SZ))\n" +
   5226 "#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*SIZE_SZ))\n" +
   5227 "\n" +
   5228 "/* The smallest possible chunk */\n" +
   5229 "#define MIN_CHUNK_SIZE        (sizeof(struct malloc_chunk))\n" +
   5230 "\n" +
   5231 "/* The smallest size we can malloc is an aligned minimal chunk */\n" +
   5232 "\n" +
   5233 "#define MINSIZE  \\n" +
   5234 "  (CHUNK_SIZE_T)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK))\n" +
   5235 "\n" +
   5236 "/* Check if m has acceptable alignment */\n" +
   5237 "\n" +
   5238 "#define aligned_OK(m)  (((PTR_UINT)((m)) & (MALLOC_ALIGN_MASK)) == 0)\n" +
   5239 "\n" +
   5240 "\n" +
   5241 "/*\n" +
   5242 "   Check if a request is so large that it would wrap around zero when\n" +
   5243 "   padded and aligned. To simplify some other code, the bound is made\n" +
   5244 "   low enough so that adding MINSIZE will also not wrap around sero.\n" +
   5245 "*/\n" +
   5246 "\n" +
   5247 "#define REQUEST_OUT_OF_RANGE(req)                                 \\n" +
   5248 "  ((CHUNK_SIZE_T)(req) >=                                        \\n" +
   5249 "   (CHUNK_SIZE_T)(INTERNAL_SIZE_T)(-2 * MINSIZE))\n" +
   5250 "\n" +
   5251 "/* pad request bytes into a usable size -- internal version */\n" +
   5252 "\n" +
   5253 "#define request2size(req)                                         \\n" +
   5254 "  (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE)  ?             \\n" +
   5255 "   MINSIZE :                                                      \\n" +
   5256 "   ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)\n" +
   5257 "\n" +
   5258 "/*  Same, except also perform argument check */\n" +
   5259 "\n" +
   5260 "#define checked_request2size(req, sz)                             \\n" +
   5261 "  if (REQUEST_OUT_OF_RANGE(req)) {                                \\n" +
   5262 "    MALLOC_FAILURE_ACTION;                                        \\n" +
   5263 "    return 0;                                                     \\n" +
   5264 "  }                                                               \\n" +
   5265 "  (sz) = request2size(req);\n" +
   5266 "\n" +
   5267 "/*\n" +
   5268 "  --------------- Physical chunk operations ---------------\n" +
   5269 "*/\n" +
   5270 "\n" +
   5271 "\n" +
   5272 "/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */\n" +
   5273 "#define PREV_INUSE 0x1\n" +
   5274 "\n" +
   5275 "/* extract inuse bit of previous chunk */\n" +
   5276 "#define prev_inuse(p)       ((p)->size & PREV_INUSE)\n" +
   5277 "\n" +
   5278 "\n" +
   5279 "/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */\n" +
   5280 "#define IS_MMAPPED 0x2\n" +
   5281 "\n" +
   5282 "/* check for mmap()'ed chunk */\n" +
   5283 "#define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED)\n" +
   5284 "\n" +
   5285 "/*\n" +
   5286 "  Bits to mask off when extracting size\n" +
   5287 "\n" +
   5288 "  Note: IS_MMAPPED is intentionally not masked off from size field in\n" +
   5289 "  macros for which mmapped chunks should never be seen. This should\n" +
   5290 "  cause helpful core dumps to occur if it is tried by accident by\n" +
   5291 "  people extending or adapting this malloc.\n" +
   5292 "*/\n" +
   5293 "#define SIZE_BITS (PREV_INUSE|IS_MMAPPED)\n" +
   5294 "\n" +
   5295 "/* Get size, ignoring use bits */\n" +
   5296 "#define chunksize(p)         ((p)->size & ~(SIZE_BITS))\n" +
   5297 "\n" +
   5298 "\n" +
   5299 "/* Ptr to next physical malloc_chunk. */\n" +
   5300 "#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~PREV_INUSE) ))\n" +
   5301 "\n" +
   5302 "/* Ptr to previous physical malloc_chunk */\n" +
   5303 "#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) ))\n" +
   5304 "\n" +
   5305 "/* Treat space at ptr + offset as a chunk */\n" +
   5306 "#define chunk_at_offset(p, s)  ((mchunkptr)(((char*)(p)) + (s)))\n" +
   5307 "\n" +
   5308 "/* extract p's inuse bit */\n" +
   5309 "#define inuse(p)\\n" +
   5310 "((((mchunkptr)(((char*)(p))+((p)->size & ~PREV_INUSE)))->size) & PREV_INUSE)\n" +
   5311 "\n" +
   5312 "/* set/clear chunk as being inuse without otherwise disturbing */\n" +
   5313 "#define set_inuse(p)\\n" +
   5314 "((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size |= PREV_INUSE\n" +
   5315 "\n") +
   5316 ("#define clear_inuse(p)\\n" +
   5317 "((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size &= ~(PREV_INUSE)\n" +
   5318 "\n" +
   5319 "\n" +
   5320 "/* check/set/clear inuse bits in known places */\n" +
   5321 "#define inuse_bit_at_offset(p, s)\\n" +
   5322 " (((mchunkptr)(((char*)(p)) + (s)))->size & PREV_INUSE)\n" +
   5323 "\n" +
   5324 "#define set_inuse_bit_at_offset(p, s)\\n" +
   5325 " (((mchunkptr)(((char*)(p)) + (s)))->size |= PREV_INUSE)\n" +
   5326 "\n" +
   5327 "#define clear_inuse_bit_at_offset(p, s)\\n" +
   5328 " (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE))\n" +
   5329 "\n" +
   5330 "\n" +
   5331 "/* Set size at head, without disturbing its use bit */\n" +
   5332 "#define set_head_size(p, s)  ((p)->size = (((p)->size & PREV_INUSE) | (s)))\n" +
   5333 "\n" +
   5334 "/* Set size/use field */\n" +
   5335 "#define set_head(p, s)       ((p)->size = (s))\n" +
   5336 "\n" +
   5337 "/* Set size at footer (only when chunk is not in use) */\n" +
   5338 "#define set_foot(p, s)       (((mchunkptr)((char*)(p) + (s)))->prev_size = (s))\n" +
   5339 "\n" +
   5340 "\n" +
   5341 "/*\n" +
   5342 "  -------------------- Internal data structures --------------------\n" +
   5343 "\n" +
   5344 "   All internal state is held in an instance of malloc_state defined\n" +
   5345 "   below. There are no other static variables, except in two optional\n" +
   5346 "   cases:\n" +
   5347 "   * If USE_MALLOC_LOCK is defined, the mALLOC_MUTEx declared above.\n" +
   5348 "   * If HAVE_MMAP is true, but mmap doesn't support\n" +
   5349 "     MAP_ANONYMOUS, a dummy file descriptor for mmap.\n" +
   5350 "\n" +
   5351 "   Beware of lots of tricks that minimize the total bookkeeping space\n" +
   5352 "   requirements. The result is a little over 1K bytes (for 4byte\n" +
   5353 "   pointers and size_t.)\n" +
   5354 "*/\n" +
   5355 "\n" +
   5356 "/*\n" +
   5357 "  Bins\n" +
   5358 "\n" +
   5359 "    An array of bin headers for free chunks. Each bin is doubly\n" +
   5360 "    linked.  The bins are approximately proportionally (log) spaced.\n" +
   5361 "    There are a lot of these bins (128). This may look excessive, but\n" +
   5362 "    works very well in practice.  Most bins hold sizes that are\n" +
   5363 "    unusual as malloc request sizes, but are more usual for fragments\n" +
   5364 "    and consolidated sets of chunks, which is what these bins hold, so\n" +
   5365 "    they can be found quickly.  All procedures maintain the invariant\n" +
   5366 "    that no consolidated chunk physically borders another one, so each\n" +
   5367 "    chunk in a list is known to be preceeded and followed by either\n" +
   5368 "    inuse chunks or the ends of memory.\n" +
   5369 "\n" +
   5370 "    Chunks in bins are kept in size order, with ties going to the\n" +
   5371 "    approximately least recently used chunk. Ordering isn't needed\n" +
   5372 "    for the small bins, which all contain the same-sized chunks, but\n" +
   5373 "    facilitates best-fit allocation for larger chunks. These lists\n" +
   5374 "    are just sequential. Keeping them in order almost never requires\n" +
   5375 "    enough traversal to warrant using fancier ordered data\n" +
   5376 "    structures.\n" +
   5377 "\n" +
   5378 "    Chunks of the same size are linked with the most\n" +
   5379 "    recently freed at the front, and allocations are taken from the\n" +
   5380 "    back.  This results in LRU (FIFO) allocation order, which tends\n" +
   5381 "    to give each chunk an equal opportunity to be consolidated with\n" +
   5382 "    adjacent freed chunks, resulting in larger free chunks and less\n" +
   5383 "    fragmentation.\n" +
   5384 "\n" +
   5385 "    To simplify use in double-linked lists, each bin header acts\n" +
   5386 "    as a malloc_chunk. This avoids special-casing for headers.\n" +
   5387 "    But to conserve space and improve locality, we allocate\n" +
   5388 "    only the fd/bk pointers of bins, and then use repositioning tricks\n" +
   5389 "    to treat these as the fields of a malloc_chunk*.\n" +
   5390 "*/\n" +
   5391 "\n" +
   5392 "typedef struct malloc_chunk* mbinptr;\n" +
   5393 "\n" +
   5394 "/* addressing -- note that bin_at(0) does not exist */\n" +
   5395 "#define bin_at(m, i) ((mbinptr)((char*)&((m)->bins[(i)<<1]) - (SIZE_SZ<<1)))\n" +
   5396 "\n" +
   5397 "/* analog of ++bin */\n" +
   5398 "#define next_bin(b)  ((mbinptr)((char*)(b) + (sizeof(mchunkptr)<<1)))\n" +
   5399 "\n" +
   5400 "/* Reminders about list directionality within bins */\n" +
   5401 "#define first(b)     ((b)->fd)\n" +
   5402 "#define last(b)      ((b)->bk)\n" +
   5403 "\n" +
   5404 "/* Take a chunk off a bin list */\n" +
   5405 "#define unlink(P, BK, FD) {                                            \\n" +
   5406 "  FD = P->fd;                                                          \\n" +
   5407 "  BK = P->bk;                                                          \\n" +
   5408 "  FD->bk = BK;                                                         \\n" +
   5409 "  BK->fd = FD;                                                         \\n" +
   5410 "}\n" +
   5411 "\n" +
   5412 "/*\n" +
   5413 "  Indexing\n" +
   5414 "\n" +
   5415 "    Bins for sizes < 512 bytes contain chunks of all the same size, spaced\n" +
   5416 "    8 bytes apart. Larger bins are approximately logarithmically spaced:\n" +
   5417 "\n" +
   5418 "    64 bins of size       8\n" +
   5419 "    32 bins of size      64\n" +
   5420 "    16 bins of size     512\n" +
   5421 "     8 bins of size    4096\n" +
   5422 "     4 bins of size   32768\n" +
   5423 "     2 bins of size  262144\n" +
   5424 "     1 bin  of size what's left\n" +
   5425 "\n" +
   5426 "    The bins top out around 1MB because we expect to service large\n" +
   5427 "    requests via mmap.\n" +
   5428 "*/\n" +
   5429 "\n" +
   5430 "#define NBINS              96\n" +
   5431 "#define NSMALLBINS         32\n" +
   5432 "#define SMALLBIN_WIDTH      8\n" +
   5433 "#define MIN_LARGE_SIZE    256\n" +
   5434 "\n" +
   5435 "#define in_smallbin_range(sz)  \\n" +
   5436 "  ((CHUNK_SIZE_T)(sz) < (CHUNK_SIZE_T)MIN_LARGE_SIZE)\n" +
   5437 "\n" +
   5438 "#define smallbin_index(sz)     (((unsigned)(sz)) >> 3)\n" +
   5439 "\n" +
   5440 "/*\n" +
   5441 "  Compute index for size. We expect this to be inlined when\n" +
   5442 "  compiled with optimization, else not, which works out well.\n" +
   5443 "*/\n" +
   5444 "static int largebin_index(unsigned int sz) {\n" +
   5445 "  unsigned int  x = sz >> SMALLBIN_WIDTH;\n" +
   5446 "  unsigned int m;            /* bit position of highest set bit of m */\n" +
   5447 "\n" +
   5448 "  if (x >= 0x10000) return NBINS-1;\n" +
   5449 "\n" +
   5450 "  /* On intel, use BSRL instruction to find highest bit */\n" +
   5451 "#if defined(__GNUC__) && defined(i386)\n" +
   5452 "\n" +
   5453 "  __asm__(\"bsrl %1,%0\\n\\t\"\n" +
   5454 "          : \"=r\" (m)\n" +
   5455 "          : \"g\"  (x));\n" +
   5456 "\n" +
   5457 "#else\n" +
   5458 "  {\n" +
   5459 "    /*\n" +
   5460 "      Based on branch-free nlz algorithm in chapter 5 of Henry\n" +
   5461 "      S. Warren Jr's book \"Hacker's Delight\".\n" +
   5462 "    */\n" +
   5463 "\n" +
   5464 "    unsigned int n = ((x - 0x100) >> 16) & 8;\n" +
   5465 "    x <<= n;\n" +
   5466 "    m = ((x - 0x1000) >> 16) & 4;\n" +
   5467 "    n += m;\n" +
   5468 "    x <<= m;\n" +
   5469 "    m = ((x - 0x4000) >> 16) & 2;\n" +
   5470 "    n += m;\n" +
   5471 "    x = (x << m) >> 14;\n" +
   5472 "    m = 13 - n + (x & ~(x>>1));\n" +
   5473 "  }\n" +
   5474 "#endif\n" +
   5475 "\n") +
   5476 (
   5477 "  /* Use next 2 bits to create finer-granularity bins */\n" +
   5478 "  return NSMALLBINS + (m << 2) + ((sz >> (m + 6)) & 3);\n" +
   5479 "}\n" +
   5480 "\n" +
   5481 "#define bin_index(sz) \\n" +
   5482 " ((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz))\n" +
   5483 "\n" +
   5484 "/*\n" +
   5485 "  FIRST_SORTED_BIN_SIZE is the chunk size corresponding to the\n" +
   5486 "  first bin that is maintained in sorted order. This must\n" +
   5487 "  be the smallest size corresponding to a given bin.\n" +
   5488 "\n" +
   5489 "  Normally, this should be MIN_LARGE_SIZE. But you can weaken\n" +
   5490 "  best fit guarantees to sometimes speed up malloc by increasing value.\n" +
   5491 "  Doing this means that malloc may choose a chunk that is\n" +
   5492 "  non-best-fitting by up to the width of the bin.\n" +
   5493 "\n" +
   5494 "  Some useful cutoff values:\n" +
   5495 "      512 - all bins sorted\n" +
   5496 "     2560 - leaves bins <=     64 bytes wide unsorted\n" +
   5497 "    12288 - leaves bins <=    512 bytes wide unsorted\n" +
   5498 "    65536 - leaves bins <=   4096 bytes wide unsorted\n" +
   5499 "   262144 - leaves bins <=  32768 bytes wide unsorted\n" +
   5500 "       -1 - no bins sorted (not recommended!)\n" +
   5501 "*/\n" +
   5502 "\n" +
   5503 "#define FIRST_SORTED_BIN_SIZE MIN_LARGE_SIZE\n" +
   5504 "/* #define FIRST_SORTED_BIN_SIZE 65536 */\n" +
   5505 "\n" +
   5506 "/*\n" +
   5507 "  Unsorted chunks\n" +
   5508 "\n" +
   5509 "    All remainders from chunk splits, as well as all returned chunks,\n" +
   5510 "    are first placed in the \"unsorted\" bin. They are then placed\n" +
   5511 "    in regular bins after malloc gives them ONE chance to be used before\n" +
   5512 "    binning. So, basically, the unsorted_chunks list acts as a queue,\n" +
   5513 "    with chunks being placed on it in free (and malloc_consolidate),\n" +
   5514 "    and taken off (to be either used or placed in bins) in malloc.\n" +
   5515 "*/\n" +
   5516 "\n" +
   5517 "/* The otherwise unindexable 1-bin is used to hold unsorted chunks. */\n" +
   5518 "#define unsorted_chunks(M)          (bin_at(M, 1))\n" +
   5519 "\n" +
   5520 "/*\n" +
   5521 "  Top\n" +
   5522 "\n" +
   5523 "    The top-most available chunk (i.e., the one bordering the end of\n" +
   5524 "    available memory) is treated specially. It is never included in\n" +
   5525 "    any bin, is used only if no other chunk is available, and is\n" +
   5526 "    released back to the system if it is very large (see\n" +
   5527 "    M_TRIM_THRESHOLD).  Because top initially\n" +
   5528 "    points to its own bin with initial zero size, thus forcing\n" +
   5529 "    extension on the first malloc request, we avoid having any special\n" +
   5530 "    code in malloc to check whether it even exists yet. But we still\n" +
   5531 "    need to do so when getting memory from system, so we make\n" +
   5532 "    initial_top treat the bin as a legal but unusable chunk during the\n" +
   5533 "    interval between initialization and the first call to\n" +
   5534 "    sYSMALLOc. (This is somewhat delicate, since it relies on\n" +
   5535 "    the 2 preceding words to be zero during this interval as well.)\n" +
   5536 "*/\n" +
   5537 "\n" +
   5538 "/* Conveniently, the unsorted bin can be used as dummy top on first call */\n" +
   5539 "#define initial_top(M)              (unsorted_chunks(M))\n" +
   5540 "\n" +
   5541 "/*\n" +
   5542 "  Binmap\n" +
   5543 "\n" +
   5544 "    To help compensate for the large number of bins, a one-level index\n" +
   5545 "    structure is used for bin-by-bin searching.  `binmap' is a\n" +
   5546 "    bitvector recording whether bins are definitely empty so they can\n" +
   5547 "    be skipped over during during traversals.  The bits are NOT always\n" +
   5548 "    cleared as soon as bins are empty, but instead only\n" +
   5549 "    when they are noticed to be empty during traversal in malloc.\n" +
   5550 "*/\n" +
   5551 "\n" +
   5552 "/* Conservatively use 32 bits per map word, even if on 64bit system */\n" +
   5553 "#define BINMAPSHIFT      5\n" +
   5554 "#define BITSPERMAP       (1U << BINMAPSHIFT)\n" +
   5555 "#define BINMAPSIZE       (NBINS / BITSPERMAP)\n" +
   5556 "\n" +
   5557 "#define idx2block(i)     ((i) >> BINMAPSHIFT)\n" +
   5558 "#define idx2bit(i)       ((1U << ((i) & ((1U << BINMAPSHIFT)-1))))\n" +
   5559 "\n" +
   5560 "#define mark_bin(m,i)    ((m)->binmap[idx2block(i)] |=  idx2bit(i))\n" +
   5561 "#define unmark_bin(m,i)  ((m)->binmap[idx2block(i)] &= ~(idx2bit(i)))\n" +
   5562 "#define get_binmap(m,i)  ((m)->binmap[idx2block(i)] &   idx2bit(i))\n" +
   5563 "\n" +
   5564 "/*\n" +
   5565 "  Fastbins\n" +
   5566 "\n" +
   5567 "    An array of lists holding recently freed small chunks.  Fastbins\n" +
   5568 "    are not doubly linked.  It is faster to single-link them, and\n" +
   5569 "    since chunks are never removed from the middles of these lists,\n" +
   5570 "    double linking is not necessary. Also, unlike regular bins, they\n" +
   5571 "    are not even processed in FIFO order (they use faster LIFO) since\n" +
   5572 "    ordering doesn't much matter in the transient contexts in which\n" +
   5573 "    fastbins are normally used.\n" +
   5574 "\n" +
   5575 "    Chunks in fastbins keep their inuse bit set, so they cannot\n" +
   5576 "    be consolidated with other free chunks. malloc_consolidate\n" +
   5577 "    releases all chunks in fastbins and consolidates them with\n" +
   5578 "    other free chunks.\n" +
   5579 "*/\n" +
   5580 "\n" +
   5581 "typedef struct malloc_chunk* mfastbinptr;\n" +
   5582 "\n" +
   5583 "/* offset 2 to use otherwise unindexable first 2 bins */\n" +
   5584 "#define fastbin_index(sz)        ((((unsigned int)(sz)) >> 3) - 2)\n" +
   5585 "\n" +
   5586 "/* The maximum fastbin request size we support */\n" +
   5587 "#define MAX_FAST_SIZE     80\n" +
   5588 "\n" +
   5589 "#define NFASTBINS  (fastbin_index(request2size(MAX_FAST_SIZE))+1)\n" +
   5590 "\n" +
   5591 "/*\n" +
   5592 "  FASTBIN_CONSOLIDATION_THRESHOLD is the size of a chunk in free()\n" +
   5593 "  that triggers automatic consolidation of possibly-surrounding\n" +
   5594 "  fastbin chunks. This is a heuristic, so the exact value should not\n" +
   5595 "  matter too much. It is defined at half the default trim threshold as a\n" +
   5596 "  compromise heuristic to only attempt consolidation if it is likely\n" +
   5597 "  to lead to trimming. However, it is not dynamically tunable, since\n" +
   5598 "  consolidation reduces fragmentation surrounding loarge chunks even\n" +
   5599 "  if trimming is not used.\n" +
   5600 "*/\n" +
   5601 "\n" +
   5602 "#define FASTBIN_CONSOLIDATION_THRESHOLD  \\n" +
   5603 "  ((unsigned long)(DEFAULT_TRIM_THRESHOLD) >> 1)\n" +
   5604 "\n" +
   5605 "/*\n" +
   5606 "  Since the lowest 2 bits in max_fast don't matter in size comparisons,\n" +
   5607 "  they are used as flags.\n" +
   5608 "*/\n" +
   5609 "\n" +
   5610 "/*\n" +
   5611 "  ANYCHUNKS_BIT held in max_fast indicates that there may be any\n" +
   5612 "  freed chunks at all. It is set true when entering a chunk into any\n" +
   5613 "  bin.\n" +
   5614 "*/\n" +
   5615 "\n" +
   5616 "#define ANYCHUNKS_BIT        (1U)\n" +
   5617 "\n" +
   5618 "#define have_anychunks(M)     (((M)->max_fast &  ANYCHUNKS_BIT))\n" +
   5619 "#define set_anychunks(M)      ((M)->max_fast |=  ANYCHUNKS_BIT)\n" +
   5620 "#define clear_anychunks(M)    ((M)->max_fast &= ~ANYCHUNKS_BIT)\n" +
   5621 "\n" +
   5622 "/*\n" +
   5623 "  FASTCHUNKS_BIT held in max_fast indicates that there are probably\n" +
   5624 "  some fastbin chunks. It is set true on entering a chunk into any\n" +
   5625 "  fastbin, and cleared only in malloc_consolidate.\n" +
   5626 "*/\n" +
   5627 "\n") +
   5628 (
   5629 "#define FASTCHUNKS_BIT        (2U)\n" +
   5630 "\n" +
   5631 "#define have_fastchunks(M)   (((M)->max_fast &  FASTCHUNKS_BIT))\n" +
   5632 "#define set_fastchunks(M)    ((M)->max_fast |=  (FASTCHUNKS_BIT|ANYCHUNKS_BIT))\n" +
   5633 "#define clear_fastchunks(M)  ((M)->max_fast &= ~(FASTCHUNKS_BIT))\n" +
   5634 "\n" +
   5635 "/*\n" +
   5636 "   Set value of max_fast.\n" +
   5637 "   Use impossibly small value if 0.\n" +
   5638 "*/\n" +
   5639 "\n" +
   5640 "#define set_max_fast(M, s) \\n" +
   5641 "  (M)->max_fast = (((s) == 0)? SMALLBIN_WIDTH: request2size(s)) | \\n" +
   5642 "  ((M)->max_fast &  (FASTCHUNKS_BIT|ANYCHUNKS_BIT))\n" +
   5643 "\n" +
   5644 "#define get_max_fast(M) \\n" +
   5645 "  ((M)->max_fast & ~(FASTCHUNKS_BIT | ANYCHUNKS_BIT))\n" +
   5646 "\n" +
   5647 "\n" +
   5648 "/*\n" +
   5649 "  morecore_properties is a status word holding dynamically discovered\n" +
   5650 "  or controlled properties of the morecore function\n" +
   5651 "*/\n" +
   5652 "\n" +
   5653 "#define MORECORE_CONTIGUOUS_BIT  (1U)\n" +
   5654 "\n" +
   5655 "#define contiguous(M) \\n" +
   5656 "        (((M)->morecore_properties &  MORECORE_CONTIGUOUS_BIT))\n" +
   5657 "#define noncontiguous(M) \\n" +
   5658 "        (((M)->morecore_properties &  MORECORE_CONTIGUOUS_BIT) == 0)\n" +
   5659 "#define set_contiguous(M) \\n" +
   5660 "        ((M)->morecore_properties |=  MORECORE_CONTIGUOUS_BIT)\n" +
   5661 "#define set_noncontiguous(M) \\n" +
   5662 "        ((M)->morecore_properties &= ~MORECORE_CONTIGUOUS_BIT)\n" +
   5663 "\n" +
   5664 "\n" +
   5665 "/*\n" +
   5666 "   ----------- Internal state representation and initialization -----------\n" +
   5667 "*/\n" +
   5668 "\n" +
   5669 "struct malloc_state {\n" +
   5670 "\n" +
   5671 "  /* The maximum chunk size to be eligible for fastbin */\n" +
   5672 "  INTERNAL_SIZE_T  max_fast;   /* low 2 bits used as flags */\n" +
   5673 "\n" +
   5674 "  /* Fastbins */\n" +
   5675 "  mfastbinptr      fastbins[NFASTBINS];\n" +
   5676 "\n" +
   5677 "  /* Base of the topmost chunk -- not otherwise kept in a bin */\n" +
   5678 "  mchunkptr        top;\n" +
   5679 "\n" +
   5680 "  /* The remainder from the most recent split of a small request */\n" +
   5681 "  mchunkptr        last_remainder;\n" +
   5682 "\n" +
   5683 "  /* Normal bins packed as described above */\n" +
   5684 "  mchunkptr        bins[NBINS * 2];\n" +
   5685 "\n" +
   5686 "  /* Bitmap of bins. Trailing zero map handles cases of largest binned size */\n" +
   5687 "  unsigned int     binmap[BINMAPSIZE+1];\n" +
   5688 "\n" +
   5689 "  /* Tunable parameters */\n" +
   5690 "  CHUNK_SIZE_T     trim_threshold;\n" +
   5691 "  INTERNAL_SIZE_T  top_pad;\n" +
   5692 "  INTERNAL_SIZE_T  mmap_threshold;\n" +
   5693 "\n" +
   5694 "  /* Memory map support */\n" +
   5695 "  int              n_mmaps;\n" +
   5696 "  int              n_mmaps_max;\n" +
   5697 "  int              max_n_mmaps;\n" +
   5698 "\n" +
   5699 "  /* Cache malloc_getpagesize */\n" +
   5700 "  unsigned int     pagesize;\n" +
   5701 "\n" +
   5702 "  /* Track properties of MORECORE */\n" +
   5703 "  unsigned int     morecore_properties;\n" +
   5704 "\n" +
   5705 "  /* Statistics */\n" +
   5706 "  INTERNAL_SIZE_T  mmapped_mem;\n" +
   5707 "  INTERNAL_SIZE_T  sbrked_mem;\n" +
   5708 "  INTERNAL_SIZE_T  max_sbrked_mem;\n" +
   5709 "  INTERNAL_SIZE_T  max_mmapped_mem;\n" +
   5710 "  INTERNAL_SIZE_T  max_total_mem;\n" +
   5711 "};\n" +
   5712 "\n" +
   5713 "typedef struct malloc_state *mstate;\n" +
   5714 "\n" +
   5715 "/*\n" +
   5716 "   There is exactly one instance of this struct in this malloc.\n" +
   5717 "   If you are adapting this malloc in a way that does NOT use a static\n" +
   5718 "   malloc_state, you MUST explicitly zero-fill it before using. This\n" +
   5719 "   malloc relies on the property that malloc_state is initialized to\n" +
   5720 "   all zeroes (as is true of C statics).\n" +
   5721 "*/\n" +
   5722 "\n" +
   5723 "static struct malloc_state av_;  /* never directly referenced */\n" +
   5724 "\n" +
   5725 "/*\n" +
   5726 "   All uses of av_ are via get_malloc_state().\n" +
   5727 "   At most one \"call\" to get_malloc_state is made per invocation of\n" +
   5728 "   the public versions of malloc and free, but other routines\n" +
   5729 "   that in turn invoke malloc and/or free may call more then once.\n" +
   5730 "   Also, it is called in check* routines if DEBUG is set.\n" +
   5731 "*/\n" +
   5732 "\n" +
   5733 "#define get_malloc_state() (&(av_))\n" +
   5734 "\n" +
   5735 "/*\n" +
   5736 "  Initialize a malloc_state struct.\n" +
   5737 "\n" +
   5738 "  This is called only from within malloc_consolidate, which needs\n" +
   5739 "  be called in the same contexts anyway.  It is never called directly\n" +
   5740 "  outside of malloc_consolidate because some optimizing compilers try\n" +
   5741 "  to inline it at all call points, which turns out not to be an\n" +
   5742 "  optimization at all. (Inlining it in malloc_consolidate is fine though.)\n" +
   5743 "*/\n" +
   5744 "\n" +
   5745 "#if __STD_C\n" +
   5746 "static void malloc_init_state(mstate av)\n" +
   5747 "#else\n" +
   5748 "static void malloc_init_state(av) mstate av;\n" +
   5749 "#endif\n" +
   5750 "{\n" +
   5751 "  int     i;\n" +
   5752 "  mbinptr bin;\n" +
   5753 "\n" +
   5754 "  /* Establish circular links for normal bins */\n" +
   5755 "  for (i = 1; i < NBINS; ++i) {\n" +
   5756 "    bin = bin_at(av,i);\n" +
   5757 "    bin->fd = bin->bk = bin;\n" +
   5758 "  }\n" +
   5759 "\n" +
   5760 "  av->top_pad        = DEFAULT_TOP_PAD;\n" +
   5761 "  av->n_mmaps_max    = DEFAULT_MMAP_MAX;\n" +
   5762 "  av->mmap_threshold = DEFAULT_MMAP_THRESHOLD;\n" +
   5763 "  av->trim_threshold = DEFAULT_TRIM_THRESHOLD;\n" +
   5764 "\n" +
   5765 "#if MORECORE_CONTIGUOUS\n" +
   5766 "  set_contiguous(av);\n" +
   5767 "#else\n" +
   5768 "  set_noncontiguous(av);\n" +
   5769 "#endif\n" +
   5770 "\n" +
   5771 "\n" +
   5772 "  set_max_fast(av, DEFAULT_MXFAST);\n" +
   5773 "\n" +
   5774 "  av->top            = initial_top(av);\n" +
   5775 "  av->pagesize       = malloc_getpagesize;\n" +
   5776 "}\n" +
   5777 "\n" +
   5778 "/*\n" +
   5779 "   Other internal utilities operating on mstates\n" +
   5780 "*/\n" +
   5781 "\n") +
   5782 (
   5783 "#if __STD_C\n" +
   5784 "static Void_t*  sYSMALLOc(INTERNAL_SIZE_T, mstate);\n" +
   5785 "#ifndef MORECORE_CANNOT_TRIM\n" +
   5786 "static int      sYSTRIm(size_t, mstate);\n" +
   5787 "#endif\n" +
   5788 "static void     malloc_consolidate(mstate);\n" +
   5789 "static Void_t** iALLOc(size_t, size_t*, int, Void_t**);\n" +
   5790 "#else\n" +
   5791 "static Void_t*  sYSMALLOc();\n" +
   5792 "static int      sYSTRIm();\n" +
   5793 "static void     malloc_consolidate();\n" +
   5794 "static Void_t** iALLOc();\n" +
   5795 "#endif\n" +
   5796 "\n" +
   5797 "/*\n" +
   5798 "  Debugging support\n" +
   5799 "\n" +
   5800 "  These routines make a number of assertions about the states\n" +
   5801 "  of data structures that should be true at all times. If any\n" +
   5802 "  are not true, it's very likely that a user program has somehow\n" +
   5803 "  trashed memory. (It's also possible that there is a coding error\n" +
   5804 "  in malloc. In which case, please report it!)\n" +
   5805 "*/\n" +
   5806 "\n" +
   5807 "#if ! DEBUG\n" +
   5808 "\n" +
   5809 "#define check_chunk(P)\n" +
   5810 "#define check_free_chunk(P)\n" +
   5811 "#define check_inuse_chunk(P)\n" +
   5812 "#define check_remalloced_chunk(P,N)\n" +
   5813 "#define check_malloced_chunk(P,N)\n" +
   5814 "#define check_malloc_state()\n" +
   5815 "\n" +
   5816 "#else\n" +
   5817 "#define check_chunk(P)              do_check_chunk(P)\n" +
   5818 "#define check_free_chunk(P)         do_check_free_chunk(P)\n" +
   5819 "#define check_inuse_chunk(P)        do_check_inuse_chunk(P)\n" +
   5820 "#define check_remalloced_chunk(P,N) do_check_remalloced_chunk(P,N)\n" +
   5821 "#define check_malloced_chunk(P,N)   do_check_malloced_chunk(P,N)\n" +
   5822 "#define check_malloc_state()        do_check_malloc_state()\n" +
   5823 "\n" +
   5824 "/*\n" +
   5825 "  Properties of all chunks\n" +
   5826 "*/\n" +
   5827 "\n" +
   5828 "#if __STD_C\n" +
   5829 "static void do_check_chunk(mchunkptr p)\n" +
   5830 "#else\n" +
   5831 "static void do_check_chunk(p) mchunkptr p;\n" +
   5832 "#endif\n" +
   5833 "{\n" +
   5834 "  mstate av = get_malloc_state();\n" +
   5835 "  CHUNK_SIZE_T  sz = chunksize(p);\n" +
   5836 "  /* min and max possible addresses assuming contiguous allocation */\n" +
   5837 "  char* max_address = (char*)(av->top) + chunksize(av->top);\n" +
   5838 "  char* min_address = max_address - av->sbrked_mem;\n" +
   5839 "\n" +
   5840 "  if (!chunk_is_mmapped(p)) {\n" +
   5841 "\n" +
   5842 "    /* Has legal address ... */\n" +
   5843 "    if (p != av->top) {\n" +
   5844 "      if (contiguous(av)) {\n" +
   5845 "        assert(((char*)p) >= min_address);\n" +
   5846 "        assert(((char*)p + sz) <= ((char*)(av->top)));\n" +
   5847 "      }\n" +
   5848 "    }\n" +
   5849 "    else {\n" +
   5850 "      /* top size is always at least MINSIZE */\n" +
   5851 "      assert((CHUNK_SIZE_T)(sz) >= MINSIZE);\n" +
   5852 "      /* top predecessor always marked inuse */\n" +
   5853 "      assert(prev_inuse(p));\n" +
   5854 "    }\n" +
   5855 "\n" +
   5856 "  }\n" +
   5857 "  else {\n" +
   5858 "#if HAVE_MMAP\n" +
   5859 "    /* address is outside main heap  */\n" +
   5860 "    if (contiguous(av) && av->top != initial_top(av)) {\n" +
   5861 "      assert(((char*)p) < min_address || ((char*)p) > max_address);\n" +
   5862 "    }\n" +
   5863 "    /* chunk is page-aligned */\n" +
   5864 "    assert(((p->prev_size + sz) & (av->pagesize-1)) == 0);\n" +
   5865 "    /* mem is aligned */\n" +
   5866 "    assert(aligned_OK(chunk2mem(p)));\n" +
   5867 "#else\n" +
   5868 "    /* force an appropriate assert violation if debug set */\n" +
   5869 "    assert(!chunk_is_mmapped(p));\n" +
   5870 "#endif\n" +
   5871 "  }\n" +
   5872 "}\n" +
   5873 "\n" +
   5874 "/*\n" +
   5875 "  Properties of free chunks\n" +
   5876 "*/\n" +
   5877 "\n" +
   5878 "#if __STD_C\n" +
   5879 "static void do_check_free_chunk(mchunkptr p)\n" +
   5880 "#else\n" +
   5881 "static void do_check_free_chunk(p) mchunkptr p;\n" +
   5882 "#endif\n" +
   5883 "{\n" +
   5884 "  mstate av = get_malloc_state();\n" +
   5885 "\n" +
   5886 "  INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;\n" +
   5887 "  mchunkptr next = chunk_at_offset(p, sz);\n" +
   5888 "\n" +
   5889 "  do_check_chunk(p);\n" +
   5890 "\n" +
   5891 "  /* Chunk must claim to be free ... */\n" +
   5892 "  assert(!inuse(p));\n" +
   5893 "  assert (!chunk_is_mmapped(p));\n" +
   5894 "\n" +
   5895 "  /* Unless a special marker, must have OK fields */\n" +
   5896 "  if ((CHUNK_SIZE_T)(sz) >= MINSIZE)\n" +
   5897 "  {\n" +
   5898 "    assert((sz & MALLOC_ALIGN_MASK) == 0);\n" +
   5899 "    assert(aligned_OK(chunk2mem(p)));\n" +
   5900 "    /* ... matching footer field */\n" +
   5901 "    assert(next->prev_size == sz);\n" +
   5902 "    /* ... and is fully consolidated */\n" +
   5903 "    assert(prev_inuse(p));\n" +
   5904 "    assert (next == av->top || inuse(next));\n" +
   5905 "\n" +
   5906 "    /* ... and has minimally sane links */\n" +
   5907 "    assert(p->fd->bk == p);\n" +
   5908 "    assert(p->bk->fd == p);\n" +
   5909 "  }\n" +
   5910 "  else /* markers are always of size SIZE_SZ */\n" +
   5911 "    assert(sz == SIZE_SZ);\n" +
   5912 "}\n" +
   5913 "\n" +
   5914 "/*\n" +
   5915 "  Properties of inuse chunks\n" +
   5916 "*/\n" +
   5917 "\n" +
   5918 "#if __STD_C\n" +
   5919 "static void do_check_inuse_chunk(mchunkptr p)\n" +
   5920 "#else\n" +
   5921 "static void do_check_inuse_chunk(p) mchunkptr p;\n" +
   5922 "#endif\n" +
   5923 "{\n" +
   5924 "  mstate av = get_malloc_state();\n" +
   5925 "  mchunkptr next;\n" +
   5926 "  do_check_chunk(p);\n" +
   5927 "\n" +
   5928 "  if (chunk_is_mmapped(p))\n" +
   5929 "    return; /* mmapped chunks have no next/prev */\n" +
   5930 "\n" +
   5931 "  /* Check whether it claims to be in use ... */\n" +
   5932 "  assert(inuse(p));\n" +
   5933 "\n") +
   5934 (
   5935 "  next = next_chunk(p);\n" +
   5936 "\n" +
   5937 "  /* ... and is surrounded by OK chunks.\n" +
   5938 "    Since more things can be checked with free chunks than inuse ones,\n" +
   5939 "    if an inuse chunk borders them and debug is on, it's worth doing them.\n" +
   5940 "  */\n" +
   5941 "  if (!prev_inuse(p))  {\n" +
   5942 "    /* Note that we cannot even look at prev unless it is not inuse */\n" +
   5943 "    mchunkptr prv = prev_chunk(p);\n" +
   5944 "    assert(next_chunk(prv) == p);\n" +
   5945 "    do_check_free_chunk(prv);\n" +
   5946 "  }\n" +
   5947 "\n" +
   5948 "  if (next == av->top) {\n" +
   5949 "    assert(prev_inuse(next));\n" +
   5950 "    assert(chunksize(next) >= MINSIZE);\n" +
   5951 "  }\n" +
   5952 "  else if (!inuse(next))\n" +
   5953 "    do_check_free_chunk(next);\n" +
   5954 "}\n" +
   5955 "\n" +
   5956 "/*\n" +
   5957 "  Properties of chunks recycled from fastbins\n" +
   5958 "*/\n" +
   5959 "\n" +
   5960 "#if __STD_C\n" +
   5961 "static void do_check_remalloced_chunk(mchunkptr p, INTERNAL_SIZE_T s)\n" +
   5962 "#else\n" +
   5963 "static void do_check_remalloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;\n" +
   5964 "#endif\n" +
   5965 "{\n" +
   5966 "  INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;\n" +
   5967 "\n" +
   5968 "  do_check_inuse_chunk(p);\n" +
   5969 "\n" +
   5970 "  /* Legal size ... */\n" +
   5971 "  assert((sz & MALLOC_ALIGN_MASK) == 0);\n" +
   5972 "  assert((CHUNK_SIZE_T)(sz) >= MINSIZE);\n" +
   5973 "  /* ... and alignment */\n" +
   5974 "  assert(aligned_OK(chunk2mem(p)));\n" +
   5975 "  /* chunk is less than MINSIZE more than request */\n" +
   5976 "  assert((long)(sz) - (long)(s) >= 0);\n" +
   5977 "  assert((long)(sz) - (long)(s + MINSIZE) < 0);\n" +
   5978 "}\n" +
   5979 "\n" +
   5980 "/*\n" +
   5981 "  Properties of nonrecycled chunks at the point they are malloced\n" +
   5982 "*/\n" +
   5983 "\n" +
   5984 "#if __STD_C\n" +
   5985 "static void do_check_malloced_chunk(mchunkptr p, INTERNAL_SIZE_T s)\n" +
   5986 "#else\n" +
   5987 "static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;\n" +
   5988 "#endif\n" +
   5989 "{\n" +
   5990 "  /* same as recycled case ... */\n" +
   5991 "  do_check_remalloced_chunk(p, s);\n" +
   5992 "\n" +
   5993 "  /*\n" +
   5994 "    ... plus,  must obey implementation invariant that prev_inuse is\n" +
   5995 "    always true of any allocated chunk; i.e., that each allocated\n" +
   5996 "    chunk borders either a previously allocated and still in-use\n" +
   5997 "    chunk, or the base of its memory arena. This is ensured\n" +
   5998 "    by making all allocations from the the `lowest' part of any found\n" +
   5999 "    chunk.  This does not necessarily hold however for chunks\n" +
   6000 "    recycled via fastbins.\n" +
   6001 "  */\n" +
   6002 "\n" +
   6003 "  assert(prev_inuse(p));\n" +
   6004 "}\n" +
   6005 "\n" +
   6006 "\n" +
   6007 "/*\n" +
   6008 "  Properties of malloc_state.\n" +
   6009 "\n" +
   6010 "  This may be useful for debugging malloc, as well as detecting user\n" +
   6011 "  programmer errors that somehow write into malloc_state.\n" +
   6012 "\n" +
   6013 "  If you are extending or experimenting with this malloc, you can\n" +
   6014 "  probably figure out how to hack this routine to print out or\n" +
   6015 "  display chunk addresses, sizes, bins, and other instrumentation.\n" +
   6016 "*/\n" +
   6017 "\n" +
   6018 "static void do_check_malloc_state()\n" +
   6019 "{\n" +
   6020 "  mstate av = get_malloc_state();\n" +
   6021 "  unsigned int i;\n" +
   6022 "  mchunkptr p;\n" +
   6023 "  mchunkptr q;\n" +
   6024 "  mbinptr b;\n" +
   6025 "  unsigned int binbit;\n" +
   6026 "  int empty;\n" +
   6027 "  unsigned int idx;\n" +
   6028 "  INTERNAL_SIZE_T size;\n" +
   6029 "  CHUNK_SIZE_T  total = 0;\n" +
   6030 "  int max_fast_bin;\n" +
   6031 "\n" +
   6032 "  /* internal size_t must be no wider than pointer type */\n" +
   6033 "  assert(sizeof(INTERNAL_SIZE_T) <= sizeof(char*));\n" +
   6034 "\n" +
   6035 "  /* alignment is a power of 2 */\n" +
   6036 "  assert((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-1)) == 0);\n" +
   6037 "\n" +
   6038 "  /* cannot run remaining checks until fully initialized */\n" +
   6039 "  if (av->top == 0 || av->top == initial_top(av))\n" +
   6040 "    return;\n" +
   6041 "\n" +
   6042 "  /* pagesize is a power of 2 */\n" +
   6043 "  assert((av->pagesize & (av->pagesize-1)) == 0);\n" +
   6044 "\n" +
   6045 "  /* properties of fastbins */\n" +
   6046 "\n" +
   6047 "  /* max_fast is in allowed range */\n" +
   6048 "  assert(get_max_fast(av) <= request2size(MAX_FAST_SIZE));\n" +
   6049 "\n" +
   6050 "  max_fast_bin = fastbin_index(av->max_fast);\n" +
   6051 "\n" +
   6052 "  for (i = 0; i < NFASTBINS; ++i) {\n" +
   6053 "    p = av->fastbins[i];\n" +
   6054 "\n" +
   6055 "    /* all bins past max_fast are empty */\n" +
   6056 "    if (i > max_fast_bin)\n" +
   6057 "      assert(p == 0);\n" +
   6058 "\n" +
   6059 "    while (p != 0) {\n" +
   6060 "      /* each chunk claims to be inuse */\n" +
   6061 "      do_check_inuse_chunk(p);\n" +
   6062 "      total += chunksize(p);\n" +
   6063 "      /* chunk belongs in this bin */\n" +
   6064 "      assert(fastbin_index(chunksize(p)) == i);\n" +
   6065 "      p = p->fd;\n" +
   6066 "    }\n" +
   6067 "  }\n" +
   6068 "\n" +
   6069 "  if (total != 0)\n" +
   6070 "    assert(have_fastchunks(av));\n" +
   6071 "  else if (!have_fastchunks(av))\n" +
   6072 "    assert(total == 0);\n" +
   6073 "\n" +
   6074 "  /* check normal bins */\n" +
   6075 "  for (i = 1; i < NBINS; ++i) {\n" +
   6076 "    b = bin_at(av,i);\n" +
   6077 "\n" +
   6078 "    /* binmap is accurate (except for bin 1 == unsorted_chunks) */\n" +
   6079 "    if (i >= 2) {\n" +
   6080 "      binbit = get_binmap(av,i);\n" +
   6081 "      empty = last(b) == b;\n" +
   6082 "      if (!binbit)\n" +
   6083 "        assert(empty);\n" +
   6084 "      else if (!empty)\n" +
   6085 "        assert(binbit);\n" +
   6086 "    }\n" +
   6087 "\n") +
   6088 (
   6089 "    for (p = last(b); p != b; p = p->bk) {\n" +
   6090 "      /* each chunk claims to be free */\n" +
   6091 "      do_check_free_chunk(p);\n" +
   6092 "      size = chunksize(p);\n" +
   6093 "      total += size;\n" +
   6094 "      if (i >= 2) {\n" +
   6095 "        /* chunk belongs in bin */\n" +
   6096 "        idx = bin_index(size);\n" +
   6097 "        assert(idx == i);\n" +
   6098 "        /* lists are sorted */\n" +
   6099 "        if ((CHUNK_SIZE_T) size >= (CHUNK_SIZE_T)(FIRST_SORTED_BIN_SIZE)) {\n" +
   6100 "          assert(p->bk == b ||\n" +
   6101 "                 (CHUNK_SIZE_T)chunksize(p->bk) >=\n" +
   6102 "                 (CHUNK_SIZE_T)chunksize(p));\n" +
   6103 "        }\n" +
   6104 "      }\n" +
   6105 "      /* chunk is followed by a legal chain of inuse chunks */\n" +
   6106 "      for (q = next_chunk(p);\n" +
   6107 "           (q != av->top && inuse(q) &&\n" +
   6108 "             (CHUNK_SIZE_T)(chunksize(q)) >= MINSIZE);\n" +
   6109 "           q = next_chunk(q))\n" +
   6110 "        do_check_inuse_chunk(q);\n" +
   6111 "    }\n" +
   6112 "  }\n" +
   6113 "\n" +
   6114 "  /* top chunk is OK */\n" +
   6115 "  check_chunk(av->top);\n" +
   6116 "\n" +
   6117 "  /* sanity checks for statistics */\n" +
   6118 "\n" +
   6119 "  assert(total <= (CHUNK_SIZE_T)(av->max_total_mem));\n" +
   6120 "  assert(av->n_mmaps >= 0);\n" +
   6121 "  assert(av->n_mmaps <= av->max_n_mmaps);\n" +
   6122 "\n" +
   6123 "  assert((CHUNK_SIZE_T)(av->sbrked_mem) <=\n" +
   6124 "         (CHUNK_SIZE_T)(av->max_sbrked_mem));\n" +
   6125 "\n" +
   6126 "  assert((CHUNK_SIZE_T)(av->mmapped_mem) <=\n" +
   6127 "         (CHUNK_SIZE_T)(av->max_mmapped_mem));\n" +
   6128 "\n" +
   6129 "  assert((CHUNK_SIZE_T)(av->max_total_mem) >=\n" +
   6130 "         (CHUNK_SIZE_T)(av->mmapped_mem) + (CHUNK_SIZE_T)(av->sbrked_mem));\n" +
   6131 "}\n" +
   6132 "#endif\n" +
   6133 "\n" +
   6134 "\n" +
   6135 "/* ----------- Routines dealing with system allocation -------------- */\n" +
   6136 "\n" +
   6137 "/*\n" +
   6138 "  sysmalloc handles malloc cases requiring more memory from the system.\n" +
   6139 "  On entry, it is assumed that av->top does not have enough\n" +
   6140 "  space to service request for nb bytes, thus requiring that av->top\n" +
   6141 "  be extended or replaced.\n" +
   6142 "*/\n" +
   6143 "\n" +
   6144 "#if __STD_C\n" +
   6145 "static Void_t* sYSMALLOc(INTERNAL_SIZE_T nb, mstate av)\n" +
   6146 "#else\n" +
   6147 "static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av;\n" +
   6148 "#endif\n" +
   6149 "{\n" +
   6150 "  mchunkptr       old_top;        /* incoming value of av->top */\n" +
   6151 "  INTERNAL_SIZE_T old_size;       /* its size */\n" +
   6152 "  char*           old_end;        /* its end address */\n" +
   6153 "\n" +
   6154 "  long            size;           /* arg to first MORECORE or mmap call */\n" +
   6155 "  char*           brk;            /* return value from MORECORE */\n" +
   6156 "\n" +
   6157 "  long            correction;     /* arg to 2nd MORECORE call */\n" +
   6158 "  char*           snd_brk;        /* 2nd return val */\n" +
   6159 "\n" +
   6160 "  INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */\n" +
   6161 "  INTERNAL_SIZE_T end_misalign;   /* partial page left at end of new space */\n" +
   6162 "  char*           aligned_brk;    /* aligned offset into brk */\n" +
   6163 "\n" +
   6164 "  mchunkptr       p;              /* the allocated/returned chunk */\n" +
   6165 "  mchunkptr       remainder;      /* remainder from allocation */\n" +
   6166 "  CHUNK_SIZE_T    remainder_size; /* its size */\n" +
   6167 "\n" +
   6168 "  CHUNK_SIZE_T    sum;            /* for updating stats */\n" +
   6169 "\n" +
   6170 "  size_t          pagemask  = av->pagesize - 1;\n" +
   6171 "\n" +
   6172 "  /*\n" +
   6173 "    If there is space available in fastbins, consolidate and retry\n" +
   6174 "    malloc from scratch rather than getting memory from system.  This\n" +
   6175 "    can occur only if nb is in smallbin range so we didn't consolidate\n" +
   6176 "    upon entry to malloc. It is much easier to handle this case here\n" +
   6177 "    than in malloc proper.\n" +
   6178 "  */\n" +
   6179 "\n" +
   6180 "  if (have_fastchunks(av)) {\n" +
   6181 "    assert(in_smallbin_range(nb));\n" +
   6182 "    malloc_consolidate(av);\n" +
   6183 "    return mALLOc(nb - MALLOC_ALIGN_MASK);\n" +
   6184 "  }\n" +
   6185 "\n" +
   6186 "\n" +
   6187 "#if HAVE_MMAP\n" +
   6188 "\n" +
   6189 "  /*\n" +
   6190 "    If have mmap, and the request size meets the mmap threshold, and\n" +
   6191 "    the system supports mmap, and there are few enough currently\n" +
   6192 "    allocated mmapped regions, try to directly map this request\n" +
   6193 "    rather than expanding top.\n" +
   6194 "  */\n" +
   6195 "\n" +
   6196 "  if ((CHUNK_SIZE_T)(nb) >= (CHUNK_SIZE_T)(av->mmap_threshold) &&\n" +
   6197 "      (av->n_mmaps < av->n_mmaps_max)) {\n" +
   6198 "\n" +
   6199 "    char* mm;             /* return value from mmap call*/\n" +
   6200 "\n" +
   6201 "    /*\n" +
   6202 "      Round up size to nearest page.  For mmapped chunks, the overhead\n" +
   6203 "      is one SIZE_SZ unit larger than for normal chunks, because there\n" +
   6204 "      is no following chunk whose prev_size field could be used.\n" +
   6205 "    */\n" +
   6206 "    size = (nb + SIZE_SZ + MALLOC_ALIGN_MASK + pagemask) & ~pagemask;\n" +
   6207 "\n" +
   6208 "    /* Don't try if size wraps around 0 */\n" +
   6209 "    if ((CHUNK_SIZE_T)(size) > (CHUNK_SIZE_T)(nb)) {\n" +
   6210 "\n" +
   6211 "      mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));\n" +
   6212 "\n" +
   6213 "      if (mm != (char*)(MORECORE_FAILURE)) {\n" +
   6214 "\n" +
   6215 "        /*\n" +
   6216 "          The offset to the start of the mmapped region is stored\n" +
   6217 "          in the prev_size field of the chunk. This allows us to adjust\n" +
   6218 "          returned start address to meet alignment requirements here\n" +
   6219 "          and in memalign(), and still be able to compute proper\n" +
   6220 "          address argument for later munmap in free() and realloc().\n" +
   6221 "        */\n" +
   6222 "\n" +
   6223 "        front_misalign = (INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK;\n" +
   6224 "        if (front_misalign > 0) {\n" +
   6225 "          correction = MALLOC_ALIGNMENT - front_misalign;\n" +
   6226 "          p = (mchunkptr)(mm + correction);\n" +
   6227 "          p->prev_size = correction;\n" +
   6228 "          set_head(p, (size - correction) |IS_MMAPPED);\n" +
   6229 "        }\n" +
   6230 "        else {\n" +
   6231 "          p = (mchunkptr)mm;\n" +
   6232 "          p->prev_size = 0;\n" +
   6233 "          set_head(p, size|IS_MMAPPED);\n" +
   6234 "        }\n" +
   6235 "\n" +
   6236 "        /* update statistics */\n" +
   6237 "\n" +
   6238 "        if (++av->n_mmaps > av->max_n_mmaps)\n" +
   6239 "          av->max_n_mmaps = av->n_mmaps;\n" +
   6240 "\n") +
   6241 (
   6242 "        sum = av->mmapped_mem += size;\n" +
   6243 "        if (sum > (CHUNK_SIZE_T)(av->max_mmapped_mem))\n" +
   6244 "          av->max_mmapped_mem = sum;\n" +
   6245 "        sum += av->sbrked_mem;\n" +
   6246 "        if (sum > (CHUNK_SIZE_T)(av->max_total_mem))\n" +
   6247 "          av->max_total_mem = sum;\n" +
   6248 "\n" +
   6249 "        check_chunk(p);\n" +
   6250 "\n" +
   6251 "        return chunk2mem(p);\n" +
   6252 "      }\n" +
   6253 "    }\n" +
   6254 "  }\n" +
   6255 "#endif\n" +
   6256 "\n" +
   6257 "  /* Record incoming configuration of top */\n" +
   6258 "\n" +
   6259 "  old_top  = av->top;\n" +
   6260 "  old_size = chunksize(old_top);\n" +
   6261 "  old_end  = (char*)(chunk_at_offset(old_top, old_size));\n" +
   6262 "\n" +
   6263 "  brk = snd_brk = (char*)(MORECORE_FAILURE);\n" +
   6264 "\n" +
   6265 "  /*\n" +
   6266 "     If not the first time through, we require old_size to be\n" +
   6267 "     at least MINSIZE and to have prev_inuse set.\n" +
   6268 "  */\n" +
   6269 "\n" +
   6270 "  assert((old_top == initial_top(av) && old_size == 0) ||\n" +
   6271 "         ((CHUNK_SIZE_T) (old_size) >= MINSIZE &&\n" +
   6272 "          prev_inuse(old_top)));\n" +
   6273 "\n" +
   6274 "  /* Precondition: not enough current space to satisfy nb request */\n" +
   6275 "  assert((CHUNK_SIZE_T)(old_size) < (CHUNK_SIZE_T)(nb + MINSIZE));\n" +
   6276 "\n" +
   6277 "  /* Precondition: all fastbins are consolidated */\n" +
   6278 "  assert(!have_fastchunks(av));\n" +
   6279 "\n" +
   6280 "\n" +
   6281 "  /* Request enough space for nb + pad + overhead */\n" +
   6282 "\n" +
   6283 "  size = nb + av->top_pad + MINSIZE;\n" +
   6284 "\n" +
   6285 "  /*\n" +
   6286 "    If contiguous, we can subtract out existing space that we hope to\n" +
   6287 "    combine with new space. We add it back later only if\n" +
   6288 "    we don't actually get contiguous space.\n" +
   6289 "  */\n" +
   6290 "\n" +
   6291 "  if (contiguous(av))\n" +
   6292 "    size -= old_size;\n" +
   6293 "\n" +
   6294 "  /*\n" +
   6295 "    Round to a multiple of page size.\n" +
   6296 "    If MORECORE is not contiguous, this ensures that we only call it\n" +
   6297 "    with whole-page arguments.  And if MORECORE is contiguous and\n" +
   6298 "    this is not first time through, this preserves page-alignment of\n" +
   6299 "    previous calls. Otherwise, we correct to page-align below.\n" +
   6300 "  */\n" +
   6301 "\n" +
   6302 "  size = (size + pagemask) & ~pagemask;\n" +
   6303 "\n" +
   6304 "  /*\n" +
   6305 "    Don't try to call MORECORE if argument is so big as to appear\n" +
   6306 "    negative. Note that since mmap takes size_t arg, it may succeed\n" +
   6307 "    below even if we cannot call MORECORE.\n" +
   6308 "  */\n" +
   6309 "\n" +
   6310 "  if (size > 0)\n" +
   6311 "    brk = (char*)(MORECORE(size));\n" +
   6312 "\n" +
   6313 "  /*\n" +
   6314 "    If have mmap, try using it as a backup when MORECORE fails or\n" +
   6315 "    cannot be used. This is worth doing on systems that have \"holes\" in\n" +
   6316 "    address space, so sbrk cannot extend to give contiguous space, but\n" +
   6317 "    space is available elsewhere.  Note that we ignore mmap max count\n" +
   6318 "    and threshold limits, since the space will not be used as a\n" +
   6319 "    segregated mmap region.\n" +
   6320 "  */\n" +
   6321 "\n" +
   6322 "#if HAVE_MMAP\n" +
   6323 "  if (brk == (char*)(MORECORE_FAILURE)) {\n" +
   6324 "\n" +
   6325 "    /* Cannot merge with old top, so add its size back in */\n" +
   6326 "    if (contiguous(av))\n" +
   6327 "      size = (size + old_size + pagemask) & ~pagemask;\n" +
   6328 "\n" +
   6329 "    /* If we are relying on mmap as backup, then use larger units */\n" +
   6330 "    if ((CHUNK_SIZE_T)(size) < (CHUNK_SIZE_T)(MMAP_AS_MORECORE_SIZE))\n" +
   6331 "      size = MMAP_AS_MORECORE_SIZE;\n" +
   6332 "\n" +
   6333 "    /* Don't try if size wraps around 0 */\n" +
   6334 "    if ((CHUNK_SIZE_T)(size) > (CHUNK_SIZE_T)(nb)) {\n" +
   6335 "\n" +
   6336 "      brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));\n" +
   6337 "\n" +
   6338 "      if (brk != (char*)(MORECORE_FAILURE)) {\n" +
   6339 "\n" +
   6340 "        /* We do not need, and cannot use, another sbrk call to find end */\n" +
   6341 "        snd_brk = brk + size;\n" +
   6342 "\n" +
   6343 "        /*\n" +
   6344 "           Record that we no longer have a contiguous sbrk region.\n" +
   6345 "           After the first time mmap is used as backup, we do not\n" +
   6346 "           ever rely on contiguous space since this could incorrectly\n" +
   6347 "           bridge regions.\n" +
   6348 "        */\n" +
   6349 "        set_noncontiguous(av);\n" +
   6350 "      }\n" +
   6351 "    }\n" +
   6352 "  }\n" +
   6353 "#endif\n" +
   6354 "\n" +
   6355 "  if (brk != (char*)(MORECORE_FAILURE)) {\n" +
   6356 "    av->sbrked_mem += size;\n" +
   6357 "\n" +
   6358 "    /*\n" +
   6359 "      If MORECORE extends previous space, we can likewise extend top size.\n" +
   6360 "    */\n" +
   6361 "\n" +
   6362 "    if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) {\n" +
   6363 "      set_head(old_top, (size + old_size) | PREV_INUSE);\n" +
   6364 "    }\n" +
   6365 "\n" +
   6366 "    /*\n" +
   6367 "      Otherwise, make adjustments:\n" +
   6368 "\n" +
   6369 "      * If the first time through or noncontiguous, we need to call sbrk\n" +
   6370 "        just to find out where the end of memory lies.\n" +
   6371 "\n" +
   6372 "      * We need to ensure that all returned chunks from malloc will meet\n" +
   6373 "        MALLOC_ALIGNMENT\n" +
   6374 "\n" +
   6375 "      * If there was an intervening foreign sbrk, we need to adjust sbrk\n" +
   6376 "        request size to account for fact that we will not be able to\n" +
   6377 "        combine new space with existing space in old_top.\n" +
   6378 "\n" +
   6379 "      * Almost all systems internally allocate whole pages at a time, in\n" +
   6380 "        which case we might as well use the whole last page of request.\n" +
   6381 "        So we allocate enough more memory to hit a page boundary now,\n" +
   6382 "        which in turn causes future contiguous calls to page-align.\n" +
   6383 "    */\n" +
   6384 "\n" +
   6385 "    else {\n" +
   6386 "      front_misalign = 0;\n" +
   6387 "      end_misalign = 0;\n" +
   6388 "      correction = 0;\n" +
   6389 "      aligned_brk = brk;\n" +
   6390 "\n") +
   6391 (
   6392 "      /*\n" +
   6393 "        If MORECORE returns an address lower than we have seen before,\n" +
   6394 "        we know it isn't really contiguous.  This and some subsequent\n" +
   6395 "        checks help cope with non-conforming MORECORE functions and\n" +
   6396 "        the presence of \"foreign\" calls to MORECORE from outside of\n" +
   6397 "        malloc or by other threads.  We cannot guarantee to detect\n" +
   6398 "        these in all cases, but cope with the ones we do detect.\n" +
   6399 "      */\n" +
   6400 "      if (contiguous(av) && old_size != 0 && brk < old_end) {\n" +
   6401 "        set_noncontiguous(av);\n" +
   6402 "      }\n" +
   6403 "\n" +
   6404 "      /* handle contiguous cases */\n" +
   6405 "      if (contiguous(av)) {\n" +
   6406 "\n" +
   6407 "        /*\n" +
   6408 "           We can tolerate forward non-contiguities here (usually due\n" +
   6409 "           to foreign calls) but treat them as part of our space for\n" +
   6410 "           stats reporting.\n" +
   6411 "        */\n" +
   6412 "        if (old_size != 0)\n" +
   6413 "          av->sbrked_mem += brk - old_end;\n" +
   6414 "\n" +
   6415 "        /* Guarantee alignment of first new chunk made from this space */\n" +
   6416 "\n" +
   6417 "        front_misalign = (INTERNAL_SIZE_T)chunk2mem(brk) & MALLOC_ALIGN_MASK;\n" +
   6418 "        if (front_misalign > 0) {\n" +
   6419 "\n" +
   6420 "          /*\n" +
   6421 "            Skip over some bytes to arrive at an aligned position.\n" +
   6422 "            We don't need to specially mark these wasted front bytes.\n" +
   6423 "            They will never be accessed anyway because\n" +
   6424 "            prev_inuse of av->top (and any chunk created from its start)\n" +
   6425 "            is always true after initialization.\n" +
   6426 "          */\n" +
   6427 "\n" +
   6428 "          correction = MALLOC_ALIGNMENT - front_misalign;\n" +
   6429 "          aligned_brk += correction;\n" +
   6430 "        }\n" +
   6431 "\n" +
   6432 "        /*\n" +
   6433 "          If this isn't adjacent to existing space, then we will not\n" +
   6434 "          be able to merge with old_top space, so must add to 2nd request.\n" +
   6435 "        */\n" +
   6436 "\n" +
   6437 "        correction += old_size;\n" +
   6438 "\n" +
   6439 "        /* Extend the end address to hit a page boundary */\n" +
   6440 "        end_misalign = (INTERNAL_SIZE_T)(brk + size + correction);\n" +
   6441 "        correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign;\n" +
   6442 "\n" +
   6443 "        assert(correction >= 0);\n" +
   6444 "        snd_brk = (char*)(MORECORE(correction));\n" +
   6445 "\n" +
   6446 "        if (snd_brk == (char*)(MORECORE_FAILURE)) {\n" +
   6447 "          /*\n" +
   6448 "            If can't allocate correction, try to at least find out current\n" +
   6449 "            brk.  It might be enough to proceed without failing.\n" +
   6450 "          */\n" +
   6451 "          correction = 0;\n" +
   6452 "          snd_brk = (char*)(MORECORE(0));\n" +
   6453 "        }\n" +
   6454 "        else if (snd_brk < brk) {\n" +
   6455 "          /*\n" +
   6456 "            If the second call gives noncontiguous space even though\n" +
   6457 "            it says it won't, the only course of action is to ignore\n" +
   6458 "            results of second call, and conservatively estimate where\n" +
   6459 "            the first call left us. Also set noncontiguous, so this\n" +
   6460 "            won't happen again, leaving at most one hole.\n" +
   6461 "\n" +
   6462 "            Note that this check is intrinsically incomplete.  Because\n" +
   6463 "            MORECORE is allowed to give more space than we ask for,\n" +
   6464 "            there is no reliable way to detect a noncontiguity\n" +
   6465 "            producing a forward gap for the second call.\n" +
   6466 "          */\n" +
   6467 "          snd_brk = brk + size;\n" +
   6468 "          correction = 0;\n" +
   6469 "          set_noncontiguous(av);\n" +
   6470 "        }\n" +
   6471 "\n" +
   6472 "      }\n" +
   6473 "\n" +
   6474 "      /* handle non-contiguous cases */\n" +
   6475 "      else {\n" +
   6476 "        /* MORECORE/mmap must correctly align */\n" +
   6477 "        assert(aligned_OK(chunk2mem(brk)));\n" +
   6478 "\n" +
   6479 "        /* Find out current end of memory */\n" +
   6480 "        if (snd_brk == (char*)(MORECORE_FAILURE)) {\n" +
   6481 "          snd_brk = (char*)(MORECORE(0));\n" +
   6482 "          av->sbrked_mem += snd_brk - brk - size;\n" +
   6483 "        }\n" +
   6484 "      }\n" +
   6485 "\n" +
   6486 "      /* Adjust top based on results of second sbrk */\n" +
   6487 "      if (snd_brk != (char*)(MORECORE_FAILURE)) {\n" +
   6488 "        av->top = (mchunkptr)aligned_brk;\n" +
   6489 "        set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE);\n" +
   6490 "        av->sbrked_mem += correction;\n" +
   6491 "\n" +
   6492 "        /*\n" +
   6493 "          If not the first time through, we either have a\n" +
   6494 "          gap due to foreign sbrk or a non-contiguous region.  Insert a\n" +
   6495 "          double fencepost at old_top to prevent consolidation with space\n" +
   6496 "          we don't own. These fenceposts are artificial chunks that are\n" +
   6497 "          marked as inuse and are in any case too small to use.  We need\n" +
   6498 "          two to make sizes and alignments work out.\n" +
   6499 "        */\n" +
   6500 "\n" +
   6501 "        if (old_size != 0) {\n" +
   6502 "          /*\n" +
   6503 "             Shrink old_top to insert fenceposts, keeping size a\n" +
   6504 "             multiple of MALLOC_ALIGNMENT. We know there is at least\n" +
   6505 "             enough space in old_top to do this.\n" +
   6506 "          */\n" +
   6507 "          old_size = (old_size - 3*SIZE_SZ) & ~MALLOC_ALIGN_MASK;\n" +
   6508 "          set_head(old_top, old_size | PREV_INUSE);\n" +
   6509 "\n" +
   6510 "          /*\n" +
   6511 "            Note that the following assignments completely overwrite\n" +
   6512 "            old_top when old_size was previously MINSIZE.  This is\n" +
   6513 "            intentional. We need the fencepost, even if old_top otherwise gets\n" +
   6514 "            lost.\n" +
   6515 "          */\n" +
   6516 "          chunk_at_offset(old_top, old_size          )->size =\n" +
   6517 "            SIZE_SZ|PREV_INUSE;\n" +
   6518 "\n" +
   6519 "          chunk_at_offset(old_top, old_size + SIZE_SZ)->size =\n" +
   6520 "            SIZE_SZ|PREV_INUSE;\n" +
   6521 "\n" +
   6522 "          /*\n" +
   6523 "             If possible, release the rest, suppressing trimming.\n" +
   6524 "          */\n" +
   6525 "          if (old_size >= MINSIZE) {\n" +
   6526 "            INTERNAL_SIZE_T tt = av->trim_threshold;\n" +
   6527 "            av->trim_threshold = (INTERNAL_SIZE_T)(-1);\n" +
   6528 "            fREe(chunk2mem(old_top));\n" +
   6529 "            av->trim_threshold = tt;\n" +
   6530 "          }\n" +
   6531 "        }\n" +
   6532 "      }\n" +
   6533 "    }\n" +
   6534 "\n" +
   6535 "    /* Update statistics */\n" +
   6536 "    sum = av->sbrked_mem;\n" +
   6537 "    if (sum > (CHUNK_SIZE_T)(av->max_sbrked_mem))\n" +
   6538 "      av->max_sbrked_mem = sum;\n" +
   6539 "\n") +
   6540 (
   6541 "    sum += av->mmapped_mem;\n" +
   6542 "    if (sum > (CHUNK_SIZE_T)(av->max_total_mem))\n" +
   6543 "      av->max_total_mem = sum;\n" +
   6544 "\n" +
   6545 "    check_malloc_state();\n" +
   6546 "\n" +
   6547 "    /* finally, do the allocation */\n" +
   6548 "\n" +
   6549 "    p = av->top;\n" +
   6550 "    size = chunksize(p);\n" +
   6551 "\n" +
   6552 "    /* check that one of the above allocation paths succeeded */\n" +
   6553 "    if ((CHUNK_SIZE_T)(size) >= (CHUNK_SIZE_T)(nb + MINSIZE)) {\n" +
   6554 "      remainder_size = size - nb;\n" +
   6555 "      remainder = chunk_at_offset(p, nb);\n" +
   6556 "      av->top = remainder;\n" +
   6557 "      set_head(p, nb | PREV_INUSE);\n" +
   6558 "      set_head(remainder, remainder_size | PREV_INUSE);\n" +
   6559 "      check_malloced_chunk(p, nb);\n" +
   6560 "      return chunk2mem(p);\n" +
   6561 "    }\n" +
   6562 "\n" +
   6563 "  }\n" +
   6564 "\n" +
   6565 "  /* catch all failure paths */\n" +
   6566 "  MALLOC_FAILURE_ACTION;\n" +
   6567 "  return 0;\n" +
   6568 "}\n" +
   6569 "\n" +
   6570 "\n" +
   6571 "\n" +
   6572 "\n" +
   6573 "/*\n" +
   6574 "  sYSTRIm is an inverse of sorts to sYSMALLOc.  It gives memory back\n" +
   6575 "  to the system (via negative arguments to sbrk) if there is unused\n" +
   6576 "  memory at the `high' end of the malloc pool. It is called\n" +
   6577 "  automatically by free() when top space exceeds the trim\n" +
   6578 "  threshold. It is also called by the public malloc_trim routine.  It\n" +
   6579 "  returns 1 if it actually released any memory, else 0.\n" +
   6580 "*/\n" +
   6581 "\n" +
   6582 "#ifndef MORECORE_CANNOT_TRIM\n" +
   6583 "\n" +
   6584 "#if __STD_C\n" +
   6585 "static int sYSTRIm(size_t pad, mstate av)\n" +
   6586 "#else\n" +
   6587 "static int sYSTRIm(pad, av) size_t pad; mstate av;\n" +
   6588 "#endif\n" +
   6589 "{\n" +
   6590 "  long  top_size;        /* Amount of top-most memory */\n" +
   6591 "  long  extra;           /* Amount to release */\n" +
   6592 "  long  released;        /* Amount actually released */\n" +
   6593 "  char* current_brk;     /* address returned by pre-check sbrk call */\n" +
   6594 "  char* new_brk;         /* address returned by post-check sbrk call */\n" +
   6595 "  size_t pagesz;\n" +
   6596 "\n" +
   6597 "  pagesz = av->pagesize;\n" +
   6598 "  top_size = chunksize(av->top);\n" +
   6599 "\n" +
   6600 "  /* Release in pagesize units, keeping at least one page */\n" +
   6601 "  extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz;\n" +
   6602 "\n" +
   6603 "  if (extra > 0) {\n" +
   6604 "\n" +
   6605 "    /*\n" +
   6606 "      Only proceed if end of memory is where we last set it.\n" +
   6607 "      This avoids problems if there were foreign sbrk calls.\n" +
   6608 "    */\n" +
   6609 "    current_brk = (char*)(MORECORE(0));\n" +
   6610 "    if (current_brk == (char*)(av->top) + top_size) {\n" +
   6611 "\n" +
   6612 "      /*\n" +
   6613 "        Attempt to release memory. We ignore MORECORE return value,\n" +
   6614 "        and instead call again to find out where new end of memory is.\n" +
   6615 "        This avoids problems if first call releases less than we asked,\n" +
   6616 "        of if failure somehow altered brk value. (We could still\n" +
   6617 "        encounter problems if it altered brk in some very bad way,\n" +
   6618 "        but the only thing we can do is adjust anyway, which will cause\n" +
   6619 "        some downstream failure.)\n" +
   6620 "      */\n" +
   6621 "\n" +
   6622 "      MORECORE(-extra);\n" +
   6623 "      new_brk = (char*)(MORECORE(0));\n" +
   6624 "\n" +
   6625 "      if (new_brk != (char*)MORECORE_FAILURE) {\n" +
   6626 "        released = (long)(current_brk - new_brk);\n" +
   6627 "\n" +
   6628 "        if (released != 0) {\n" +
   6629 "          /* Success. Adjust top. */\n" +
   6630 "          av->sbrked_mem -= released;\n" +
   6631 "          set_head(av->top, (top_size - released) | PREV_INUSE);\n" +
   6632 "          check_malloc_state();\n" +
   6633 "          return 1;\n" +
   6634 "        }\n" +
   6635 "      }\n" +
   6636 "    }\n" +
   6637 "  }\n" +
   6638 "  return 0;\n" +
   6639 "}\n" +
   6640 "\n" +
   6641 "#endif\n" +
   6642 "\n" +
   6643 "/*\n" +
   6644 "  ------------------------------ malloc ------------------------------\n" +
   6645 "*/\n" +
   6646 "\n" +
   6647 "\n" +
   6648 "#if __STD_C\n" +
   6649 "Void_t* mALLOc(size_t bytes)\n" +
   6650 "#else\n" +
   6651 "  Void_t* mALLOc(bytes) size_t bytes;\n" +
   6652 "#endif\n" +
   6653 "{\n" +
   6654 "  mstate av = get_malloc_state();\n" +
   6655 "\n" +
   6656 "  INTERNAL_SIZE_T nb;               /* normalized request size */\n" +
   6657 "  unsigned int    idx;              /* associated bin index */\n" +
   6658 "  mbinptr         bin;              /* associated bin */\n" +
   6659 "  mfastbinptr*    fb;               /* associated fastbin */\n" +
   6660 "\n" +
   6661 "  mchunkptr       victim;           /* inspected/selected chunk */\n" +
   6662 "  INTERNAL_SIZE_T size;             /* its size */\n" +
   6663 "  int             victim_index;     /* its bin index */\n" +
   6664 "\n" +
   6665 "  mchunkptr       remainder;        /* remainder from a split */\n" +
   6666 "  CHUNK_SIZE_T    remainder_size;   /* its size */\n" +
   6667 "\n" +
   6668 "  unsigned int    block;            /* bit map traverser */\n" +
   6669 "  unsigned int    bit;              /* bit map traverser */\n" +
   6670 "  unsigned int    map;              /* current word of binmap */\n" +
   6671 "\n" +
   6672 "  mchunkptr       fwd;              /* misc temp for linking */\n" +
   6673 "  mchunkptr       bck;              /* misc temp for linking */\n" +
   6674 "\n" +
   6675 "  /*\n" +
   6676 "    Convert request size to internal form by adding SIZE_SZ bytes\n" +
   6677 "    overhead plus possibly more to obtain necessary alignment and/or\n" +
   6678 "    to obtain a size of at least MINSIZE, the smallest allocatable\n" +
   6679 "    size. Also, checked_request2size traps (returning 0) request sizes\n" +
   6680 "    that are so large that they wrap around zero when padded and\n" +
   6681 "    aligned.\n" +
   6682 "  */\n" +
   6683 "\n" +
   6684 "  checked_request2size(bytes, nb);\n" +
   6685 "\n" +
   6686 "  /*\n" +
   6687 "    Bypass search if no frees yet\n" +
   6688 "   */\n" +
   6689 "  if (!have_anychunks(av)) {\n" +
   6690 "    if (av->max_fast == 0) /* initialization check */\n" +
   6691 "      malloc_consolidate(av);\n" +
   6692 "    goto use_top;\n" +
   6693 "  }\n" +
   6694 "\n") +
   6695 (
   6696 "  /*\n" +
   6697 "    If the size qualifies as a fastbin, first check corresponding bin.\n" +
   6698 "  */\n" +
   6699 "\n" +
   6700 "  if ((CHUNK_SIZE_T)(nb) <= (CHUNK_SIZE_T)(av->max_fast)) {\n" +
   6701 "    fb = &(av->fastbins[(fastbin_index(nb))]);\n" +
   6702 "    if ( (victim = *fb) != 0) {\n" +
   6703 "      *fb = victim->fd;\n" +
   6704 "      check_remalloced_chunk(victim, nb);\n" +
   6705 "      return chunk2mem(victim);\n" +
   6706 "    }\n" +
   6707 "  }\n" +
   6708 "\n" +
   6709 "  /*\n" +
   6710 "    If a small request, check regular bin.  Since these \"smallbins\"\n" +
   6711 "    hold one size each, no searching within bins is necessary.\n" +
   6712 "    (For a large request, we need to wait until unsorted chunks are\n" +
   6713 "    processed to find best fit. But for small ones, fits are exact\n" +
   6714 "    anyway, so we can check now, which is faster.)\n" +
   6715 "  */\n" +
   6716 "\n" +
   6717 "  if (in_smallbin_range(nb)) {\n" +
   6718 "    idx = smallbin_index(nb);\n" +
   6719 "    bin = bin_at(av,idx);\n" +
   6720 "\n" +
   6721 "    if ( (victim = last(bin)) != bin) {\n" +
   6722 "      bck = victim->bk;\n" +
   6723 "      set_inuse_bit_at_offset(victim, nb);\n" +
   6724 "      bin->bk = bck;\n" +
   6725 "      bck->fd = bin;\n" +
   6726 "\n" +
   6727 "      check_malloced_chunk(victim, nb);\n" +
   6728 "      return chunk2mem(victim);\n" +
   6729 "    }\n" +
   6730 "  }\n" +
   6731 "\n" +
   6732 "  /*\n" +
   6733 "     If this is a large request, consolidate fastbins before continuing.\n" +
   6734 "     While it might look excessive to kill all fastbins before\n" +
   6735 "     even seeing if there is space available, this avoids\n" +
   6736 "     fragmentation problems normally associated with fastbins.\n" +
   6737 "     Also, in practice, programs tend to have runs of either small or\n" +
   6738 "     large requests, but less often mixtures, so consolidation is not\n" +
   6739 "     invoked all that often in most programs. And the programs that\n" +
   6740 "     it is called frequently in otherwise tend to fragment.\n" +
   6741 "  */\n" +
   6742 "\n" +
   6743 "  else {\n" +
   6744 "    idx = largebin_index(nb);\n" +
   6745 "    if (have_fastchunks(av))\n" +
   6746 "      malloc_consolidate(av);\n" +
   6747 "  }\n" +
   6748 "\n" +
   6749 "  /*\n" +
   6750 "    Process recently freed or remaindered chunks, taking one only if\n" +
   6751 "    it is exact fit, or, if this a small request, the chunk is remainder from\n" +
   6752 "    the most recent non-exact fit.  Place other traversed chunks in\n" +
   6753 "    bins.  Note that this step is the only place in any routine where\n" +
   6754 "    chunks are placed in bins.\n" +
   6755 "  */\n" +
   6756 "\n" +
   6757 "  while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) {\n" +
   6758 "    bck = victim->bk;\n" +
   6759 "    size = chunksize(victim);\n" +
   6760 "\n" +
   6761 "    /*\n" +
   6762 "       If a small request, try to use last remainder if it is the\n" +
   6763 "       only chunk in unsorted bin.  This helps promote locality for\n" +
   6764 "       runs of consecutive small requests. This is the only\n" +
   6765 "       exception to best-fit, and applies only when there is\n" +
   6766 "       no exact fit for a small chunk.\n" +
   6767 "    */\n" +
   6768 "\n" +
   6769 "    if (in_smallbin_range(nb) &&\n" +
   6770 "        bck == unsorted_chunks(av) &&\n" +
   6771 "        victim == av->last_remainder &&\n" +
   6772 "        (CHUNK_SIZE_T)(size) > (CHUNK_SIZE_T)(nb + MINSIZE)) {\n" +
   6773 "\n" +
   6774 "      /* split and reattach remainder */\n" +
   6775 "      remainder_size = size - nb;\n" +
   6776 "      remainder = chunk_at_offset(victim, nb);\n" +
   6777 "      unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder;\n" +
   6778 "      av->last_remainder = remainder;\n" +
   6779 "      remainder->bk = remainder->fd = unsorted_chunks(av);\n" +
   6780 "\n" +
   6781 "      set_head(victim, nb | PREV_INUSE);\n" +
   6782 "      set_head(remainder, remainder_size | PREV_INUSE);\n" +
   6783 "      set_foot(remainder, remainder_size);\n" +
   6784 "\n" +
   6785 "      check_malloced_chunk(victim, nb);\n" +
   6786 "      return chunk2mem(victim);\n" +
   6787 "    }\n" +
   6788 "\n" +
   6789 "    /* remove from unsorted list */\n" +
   6790 "    unsorted_chunks(av)->bk = bck;\n" +
   6791 "    bck->fd = unsorted_chunks(av);\n" +
   6792 "\n" +
   6793 "    /* Take now instead of binning if exact fit */\n" +
   6794 "\n" +
   6795 "    if (size == nb) {\n" +
   6796 "      set_inuse_bit_at_offset(victim, size);\n" +
   6797 "      check_malloced_chunk(victim, nb);\n" +
   6798 "      return chunk2mem(victim);\n" +
   6799 "    }\n" +
   6800 "\n" +
   6801 "    /* place chunk in bin */\n" +
   6802 "\n" +
   6803 "    if (in_smallbin_range(size)) {\n" +
   6804 "      victim_index = smallbin_index(size);\n" +
   6805 "      bck = bin_at(av, victim_index);\n" +
   6806 "      fwd = bck->fd;\n" +
   6807 "    }\n" +
   6808 "    else {\n" +
   6809 "      victim_index = largebin_index(size);\n" +
   6810 "      bck = bin_at(av, victim_index);\n" +
   6811 "      fwd = bck->fd;\n" +
   6812 "\n" +
   6813 "      if (fwd != bck) {\n" +
   6814 "        /* if smaller than smallest, place first */\n" +
   6815 "        if ((CHUNK_SIZE_T)(size) < (CHUNK_SIZE_T)(bck->bk->size)) {\n" +
   6816 "          fwd = bck;\n" +
   6817 "          bck = bck->bk;\n" +
   6818 "        }\n" +
   6819 "        else if ((CHUNK_SIZE_T)(size) >=\n" +
   6820 "                 (CHUNK_SIZE_T)(FIRST_SORTED_BIN_SIZE)) {\n" +
   6821 "\n" +
   6822 "          /* maintain large bins in sorted order */\n" +
   6823 "          size |= PREV_INUSE; /* Or with inuse bit to speed comparisons */\n" +
   6824 "          while ((CHUNK_SIZE_T)(size) < (CHUNK_SIZE_T)(fwd->size))\n" +
   6825 "            fwd = fwd->fd;\n" +
   6826 "          bck = fwd->bk;\n" +
   6827 "        }\n" +
   6828 "      }\n" +
   6829 "    }\n" +
   6830 "\n" +
   6831 "    mark_bin(av, victim_index);\n" +
   6832 "    victim->bk = bck;\n" +
   6833 "    victim->fd = fwd;\n" +
   6834 "    fwd->bk = victim;\n" +
   6835 "    bck->fd = victim;\n" +
   6836 "  }\n" +
   6837 "\n" +
   6838 "  /*\n" +
   6839 "    If a large request, scan through the chunks of current bin to\n" +
   6840 "    find one that fits.  (This will be the smallest that fits unless\n" +
   6841 "    FIRST_SORTED_BIN_SIZE has been changed from default.)  This is\n" +
   6842 "    the only step where an unbounded number of chunks might be\n" +
   6843 "    scanned without doing anything useful with them. However the\n" +
   6844 "    lists tend to be short.\n" +
   6845 "  */\n" +
   6846 "\n") +
   6847 (
   6848 "  if (!in_smallbin_range(nb)) {\n" +
   6849 "    bin = bin_at(av, idx);\n" +
   6850 "\n" +
   6851 "    for (victim = last(bin); victim != bin; victim = victim->bk) {\n" +
   6852 "      size = chunksize(victim);\n" +
   6853 "\n" +
   6854 "      if ((CHUNK_SIZE_T)(size) >= (CHUNK_SIZE_T)(nb)) {\n" +
   6855 "        remainder_size = size - nb;\n" +
   6856 "        unlink(victim, bck, fwd);\n" +
   6857 "\n" +
   6858 "        /* Exhaust */\n" +
   6859 "        if (remainder_size < MINSIZE)  {\n" +
   6860 "          set_inuse_bit_at_offset(victim, size);\n" +
   6861 "          check_malloced_chunk(victim, nb);\n" +
   6862 "          return chunk2mem(victim);\n" +
   6863 "        }\n" +
   6864 "        /* Split */\n" +
   6865 "        else {\n" +
   6866 "          remainder = chunk_at_offset(victim, nb);\n" +
   6867 "          unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder;\n" +
   6868 "          remainder->bk = remainder->fd = unsorted_chunks(av);\n" +
   6869 "          set_head(victim, nb | PREV_INUSE);\n" +
   6870 "          set_head(remainder, remainder_size | PREV_INUSE);\n" +
   6871 "          set_foot(remainder, remainder_size);\n" +
   6872 "          check_malloced_chunk(victim, nb);\n" +
   6873 "          return chunk2mem(victim);\n" +
   6874 "        }\n" +
   6875 "      }\n" +
   6876 "    }\n" +
   6877 "  }\n" +
   6878 "\n" +
   6879 "  /*\n" +
   6880 "    Search for a chunk by scanning bins, starting with next largest\n" +
   6881 "    bin. This search is strictly by best-fit; i.e., the smallest\n" +
   6882 "    (with ties going to approximately the least recently used) chunk\n" +
   6883 "    that fits is selected.\n" +
   6884 "\n" +
   6885 "    The bitmap avoids needing to check that most blocks are nonempty.\n" +
   6886 "  */\n" +
   6887 "\n" +
   6888 "  ++idx;\n" +
   6889 "  bin = bin_at(av,idx);\n" +
   6890 "  block = idx2block(idx);\n" +
   6891 "  map = av->binmap[block];\n" +
   6892 "  bit = idx2bit(idx);\n" +
   6893 "\n" +
   6894 "  for (;;) {\n" +
   6895 "\n" +
   6896 "    /* Skip rest of block if there are no more set bits in this block.  */\n" +
   6897 "    if (bit > map || bit == 0) {\n" +
   6898 "      do {\n" +
   6899 "        if (++block >= BINMAPSIZE)  /* out of bins */\n" +
   6900 "          goto use_top;\n" +
   6901 "      } while ( (map = av->binmap[block]) == 0);\n" +
   6902 "\n" +
   6903 "      bin = bin_at(av, (block << BINMAPSHIFT));\n" +
   6904 "      bit = 1;\n" +
   6905 "    }\n" +
   6906 "\n" +
   6907 "    /* Advance to bin with set bit. There must be one. */\n" +
   6908 "    while ((bit & map) == 0) {\n" +
   6909 "      bin = next_bin(bin);\n" +
   6910 "      bit <<= 1;\n" +
   6911 "      assert(bit != 0);\n" +
   6912 "    }\n" +
   6913 "\n" +
   6914 "    /* Inspect the bin. It is likely to be non-empty */\n" +
   6915 "    victim = last(bin);\n" +
   6916 "\n" +
   6917 "    /*  If a false alarm (empty bin), clear the bit. */\n" +
   6918 "    if (victim == bin) {\n" +
   6919 "      av->binmap[block] = map &= ~bit; /* Write through */\n" +
   6920 "      bin = next_bin(bin);\n" +
   6921 "      bit <<= 1;\n" +
   6922 "    }\n" +
   6923 "\n" +
   6924 "    else {\n" +
   6925 "      size = chunksize(victim);\n" +
   6926 "\n" +
   6927 "      /*  We know the first chunk in this bin is big enough to use. */\n" +
   6928 "      assert((CHUNK_SIZE_T)(size) >= (CHUNK_SIZE_T)(nb));\n" +
   6929 "\n" +
   6930 "      remainder_size = size - nb;\n" +
   6931 "\n" +
   6932 "      /* unlink */\n" +
   6933 "      bck = victim->bk;\n" +
   6934 "      bin->bk = bck;\n" +
   6935 "      bck->fd = bin;\n" +
   6936 "\n" +
   6937 "      /* Exhaust */\n" +
   6938 "      if (remainder_size < MINSIZE) {\n" +
   6939 "        set_inuse_bit_at_offset(victim, size);\n" +
   6940 "        check_malloced_chunk(victim, nb);\n" +
   6941 "        return chunk2mem(victim);\n" +
   6942 "      }\n" +
   6943 "\n" +
   6944 "      /* Split */\n" +
   6945 "      else {\n" +
   6946 "        remainder = chunk_at_offset(victim, nb);\n" +
   6947 "\n" +
   6948 "        unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder;\n" +
   6949 "        remainder->bk = remainder->fd = unsorted_chunks(av);\n" +
   6950 "        /* advertise as last remainder */\n" +
   6951 "        if (in_smallbin_range(nb))\n" +
   6952 "          av->last_remainder = remainder;\n" +
   6953 "\n" +
   6954 "        set_head(victim, nb | PREV_INUSE);\n" +
   6955 "        set_head(remainder, remainder_size | PREV_INUSE);\n" +
   6956 "        set_foot(remainder, remainder_size);\n" +
   6957 "        check_malloced_chunk(victim, nb);\n" +
   6958 "        return chunk2mem(victim);\n" +
   6959 "      }\n" +
   6960 "    }\n" +
   6961 "  }\n" +
   6962 "\n" +
   6963 "  use_top:\n" +
   6964 "  /*\n" +
   6965 "    If large enough, split off the chunk bordering the end of memory\n" +
   6966 "    (held in av->top). Note that this is in accord with the best-fit\n" +
   6967 "    search rule.  In effect, av->top is treated as larger (and thus\n" +
   6968 "    less well fitting) than any other available chunk since it can\n" +
   6969 "    be extended to be as large as necessary (up to system\n" +
   6970 "    limitations).\n" +
   6971 "\n" +
   6972 "    We require that av->top always exists (i.e., has size >=\n" +
   6973 "    MINSIZE) after initialization, so if it would otherwise be\n" +
   6974 "    exhuasted by current request, it is replenished. (The main\n" +
   6975 "    reason for ensuring it exists is that we may need MINSIZE space\n" +
   6976 "    to put in fenceposts in sysmalloc.)\n" +
   6977 "  */\n" +
   6978 "\n" +
   6979 "  victim = av->top;\n" +
   6980 "  size = chunksize(victim);\n" +
   6981 "\n" +
   6982 "  if ((CHUNK_SIZE_T)(size) >= (CHUNK_SIZE_T)(nb + MINSIZE)) {\n" +
   6983 "    remainder_size = size - nb;\n" +
   6984 "    remainder = chunk_at_offset(victim, nb);\n" +
   6985 "    av->top = remainder;\n" +
   6986 "    set_head(victim, nb | PREV_INUSE);\n" +
   6987 "    set_head(remainder, remainder_size | PREV_INUSE);\n" +
   6988 "\n" +
   6989 "    check_malloced_chunk(victim, nb);\n" +
   6990 "    return chunk2mem(victim);\n" +
   6991 "  }\n" +
   6992 "\n" +
   6993 "  /*\n" +
   6994 "     If no space in top, relay to handle system-dependent cases\n" +
   6995 "  */\n" +
   6996 "  return sYSMALLOc(nb, av);\n" +
   6997 "}\n" +
   6998 "\n") +
   6999 (
   7000 "/*\n" +
   7001 "  ------------------------------ free ------------------------------\n" +
   7002 "*/\n" +
   7003 "\n" +
   7004 "#if __STD_C\n" +
   7005 "void fREe(Void_t* mem)\n" +
   7006 "#else\n" +
   7007 "void fREe(mem) Void_t* mem;\n" +
   7008 "#endif\n" +
   7009 "{\n" +
   7010 "  mstate av = get_malloc_state();\n" +
   7011 "\n" +
   7012 "  mchunkptr       p;           /* chunk corresponding to mem */\n" +
   7013 "  INTERNAL_SIZE_T size;        /* its size */\n" +
   7014 "  mfastbinptr*    fb;          /* associated fastbin */\n" +
   7015 "  mchunkptr       nextchunk;   /* next contiguous chunk */\n" +
   7016 "  INTERNAL_SIZE_T nextsize;    /* its size */\n" +
   7017 "  int             nextinuse;   /* true if nextchunk is used */\n" +
   7018 "  INTERNAL_SIZE_T prevsize;    /* size of previous contiguous chunk */\n" +
   7019 "  mchunkptr       bck;         /* misc temp for linking */\n" +
   7020 "  mchunkptr       fwd;         /* misc temp for linking */\n" +
   7021 "\n" +
   7022 "  /* free(0) has no effect */\n" +
   7023 "  if (mem != 0) {\n" +
   7024 "    p = mem2chunk(mem);\n" +
   7025 "    size = chunksize(p);\n" +
   7026 "\n" +
   7027 "    check_inuse_chunk(p);\n" +
   7028 "\n" +
   7029 "    /*\n" +
   7030 "      If eligible, place chunk on a fastbin so it can be found\n" +
   7031 "      and used quickly in malloc.\n" +
   7032 "    */\n" +
   7033 "\n" +
   7034 "    if ((CHUNK_SIZE_T)(size) <= (CHUNK_SIZE_T)(av->max_fast)\n" +
   7035 "\n" +
   7036 "#if TRIM_FASTBINS\n" +
   7037 "        /*\n" +
   7038 "           If TRIM_FASTBINS set, don't place chunks\n" +
   7039 "           bordering top into fastbins\n" +
   7040 "        */\n" +
   7041 "        && (chunk_at_offset(p, size) != av->top)\n" +
   7042 "#endif\n" +
   7043 "        ) {\n" +
   7044 "\n" +
   7045 "      set_fastchunks(av);\n" +
   7046 "      fb = &(av->fastbins[fastbin_index(size)]);\n" +
   7047 "      p->fd = *fb;\n" +
   7048 "      *fb = p;\n" +
   7049 "    }\n" +
   7050 "\n" +
   7051 "    /*\n" +
   7052 "       Consolidate other non-mmapped chunks as they arrive.\n" +
   7053 "    */\n" +
   7054 "\n" +
   7055 "    else if (!chunk_is_mmapped(p)) {\n" +
   7056 "      set_anychunks(av);\n" +
   7057 "\n" +
   7058 "      nextchunk = chunk_at_offset(p, size);\n" +
   7059 "      nextsize = chunksize(nextchunk);\n" +
   7060 "\n" +
   7061 "      /* consolidate backward */\n" +
   7062 "      if (!prev_inuse(p)) {\n" +
   7063 "        prevsize = p->prev_size;\n" +
   7064 "        size += prevsize;\n" +
   7065 "        p = chunk_at_offset(p, -((long) prevsize));\n" +
   7066 "        unlink(p, bck, fwd);\n" +
   7067 "      }\n" +
   7068 "\n" +
   7069 "      if (nextchunk != av->top) {\n" +
   7070 "        /* get and clear inuse bit */\n" +
   7071 "        nextinuse = inuse_bit_at_offset(nextchunk, nextsize);\n" +
   7072 "        set_head(nextchunk, nextsize);\n" +
   7073 "\n" +
   7074 "        /* consolidate forward */\n" +
   7075 "        if (!nextinuse) {\n" +
   7076 "          unlink(nextchunk, bck, fwd);\n" +
   7077 "          size += nextsize;\n" +
   7078 "        }\n" +
   7079 "\n" +
   7080 "        /*\n" +
   7081 "          Place the chunk in unsorted chunk list. Chunks are\n" +
   7082 "          not placed into regular bins until after they have\n" +
   7083 "          been given one chance to be used in malloc.\n" +
   7084 "        */\n" +
   7085 "\n" +
   7086 "        bck = unsorted_chunks(av);\n" +
   7087 "        fwd = bck->fd;\n" +
   7088 "        p->bk = bck;\n" +
   7089 "        p->fd = fwd;\n" +
   7090 "        bck->fd = p;\n" +
   7091 "        fwd->bk = p;\n" +
   7092 "\n" +
   7093 "        set_head(p, size | PREV_INUSE);\n" +
   7094 "        set_foot(p, size);\n" +
   7095 "\n" +
   7096 "        check_free_chunk(p);\n" +
   7097 "      }\n" +
   7098 "\n" +
   7099 "      /*\n" +
   7100 "         If the chunk borders the current high end of memory,\n" +
   7101 "         consolidate into top\n" +
   7102 "      */\n" +
   7103 "\n" +
   7104 "      else {\n" +
   7105 "        size += nextsize;\n" +
   7106 "        set_head(p, size | PREV_INUSE);\n" +
   7107 "        av->top = p;\n" +
   7108 "        check_chunk(p);\n" +
   7109 "      }\n" +
   7110 "\n" +
   7111 "      /*\n" +
   7112 "        If freeing a large space, consolidate possibly-surrounding\n" +
   7113 "        chunks. Then, if the total unused topmost memory exceeds trim\n" +
   7114 "        threshold, ask malloc_trim to reduce top.\n" +
   7115 "\n" +
   7116 "        Unless max_fast is 0, we don't know if there are fastbins\n" +
   7117 "        bordering top, so we cannot tell for sure whether threshold\n" +
   7118 "        has been reached unless fastbins are consolidated.  But we\n" +
   7119 "        don't want to consolidate on each free.  As a compromise,\n" +
   7120 "        consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD\n" +
   7121 "        is reached.\n" +
   7122 "      */\n" +
   7123 "\n" +
   7124 "      if ((CHUNK_SIZE_T)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {\n" +
   7125 "        if (have_fastchunks(av))\n" +
   7126 "          malloc_consolidate(av);\n" +
   7127 "\n" +
   7128 "#ifndef MORECORE_CANNOT_TRIM\n" +
   7129 "        if ((CHUNK_SIZE_T)(chunksize(av->top)) >=\n" +
   7130 "            (CHUNK_SIZE_T)(av->trim_threshold))\n" +
   7131 "          sYSTRIm(av->top_pad, av);\n" +
   7132 "#endif\n" +
   7133 "      }\n" +
   7134 "\n" +
   7135 "    }\n" +
   7136 "    /*\n" +
   7137 "      If the chunk was allocated via mmap, release via munmap()\n" +
   7138 "      Note that if HAVE_MMAP is false but chunk_is_mmapped is\n" +
   7139 "      true, then user must have overwritten memory. There's nothing\n" +
   7140 "      we can do to catch this error unless DEBUG is set, in which case\n" +
   7141 "      check_inuse_chunk (above) will have triggered error.\n" +
   7142 "    */\n" +
   7143 "\n" +
   7144 "    else {\n" +
   7145 "#if HAVE_MMAP\n" +
   7146 "      int ret;\n" +
   7147 "      INTERNAL_SIZE_T offset = p->prev_size;\n" +
   7148 "      av->n_mmaps--;\n" +
   7149 "      av->mmapped_mem -= (size + offset);\n" +
   7150 "      ret = munmap((char*)p - offset, size + offset);\n" +
   7151 "      /* munmap returns non-zero on failure */\n" +
   7152 "      assert(ret == 0);\n" +
   7153 "#endif\n" +
   7154 "    }\n" +
   7155 "  }\n" +
   7156 "}\n" +
   7157 "\n") +
   7158 (
   7159 "/*\n" +
   7160 "  ------------------------- malloc_consolidate -------------------------\n" +
   7161 "\n" +
   7162 "  malloc_consolidate is a specialized version of free() that tears\n" +
   7163 "  down chunks held in fastbins.  Free itself cannot be used for this\n" +
   7164 "  purpose since, among other things, it might place chunks back onto\n" +
   7165 "  fastbins.  So, instead, we need to use a minor variant of the same\n" +
   7166 "  code.\n" +
   7167 "\n" +
   7168 "  Also, because this routine needs to be called the first time through\n" +
   7169 "  malloc anyway, it turns out to be the perfect place to trigger\n" +
   7170 "  initialization code.\n" +
   7171 "*/\n" +
   7172 "\n" +
   7173 "#if __STD_C\n" +
   7174 "static void malloc_consolidate(mstate av)\n" +
   7175 "#else\n" +
   7176 "static void malloc_consolidate(av) mstate av;\n" +
   7177 "#endif\n" +
   7178 "{\n" +
   7179 "  mfastbinptr*    fb;                 /* current fastbin being consolidated */\n" +
   7180 "  mfastbinptr*    maxfb;              /* last fastbin (for loop control) */\n" +
   7181 "  mchunkptr       p;                  /* current chunk being consolidated */\n" +
   7182 "  mchunkptr       nextp;              /* next chunk to consolidate */\n" +
   7183 "  mchunkptr       unsorted_bin;       /* bin header */\n" +
   7184 "  mchunkptr       first_unsorted;     /* chunk to link to */\n" +
   7185 "\n" +
   7186 "  /* These have same use as in free() */\n" +
   7187 "  mchunkptr       nextchunk;\n" +
   7188 "  INTERNAL_SIZE_T size;\n" +
   7189 "  INTERNAL_SIZE_T nextsize;\n" +
   7190 "  INTERNAL_SIZE_T prevsize;\n" +
   7191 "  int             nextinuse;\n" +
   7192 "  mchunkptr       bck;\n" +
   7193 "  mchunkptr       fwd;\n" +
   7194 "\n" +
   7195 "  /*\n" +
   7196 "    If max_fast is 0, we know that av hasn't\n" +
   7197 "    yet been initialized, in which case do so below\n" +
   7198 "  */\n" +
   7199 "\n" +
   7200 "  if (av->max_fast != 0) {\n" +
   7201 "    clear_fastchunks(av);\n" +
   7202 "\n" +
   7203 "    unsorted_bin = unsorted_chunks(av);\n" +
   7204 "\n" +
   7205 "    /*\n" +
   7206 "      Remove each chunk from fast bin and consolidate it, placing it\n" +
   7207 "      then in unsorted bin. Among other reasons for doing this,\n" +
   7208 "      placing in unsorted bin avoids needing to calculate actual bins\n" +
   7209 "      until malloc is sure that chunks aren't immediately going to be\n" +
   7210 "      reused anyway.\n" +
   7211 "    */\n" +
   7212 "\n" +
   7213 "    maxfb = &(av->fastbins[fastbin_index(av->max_fast)]);\n" +
   7214 "    fb = &(av->fastbins[0]);\n" +
   7215 "    do {\n" +
   7216 "      if ( (p = *fb) != 0) {\n" +
   7217 "        *fb = 0;\n" +
   7218 "\n" +
   7219 "        do {\n" +
   7220 "          check_inuse_chunk(p);\n" +
   7221 "          nextp = p->fd;\n" +
   7222 "\n" +
   7223 "          /* Slightly streamlined version of consolidation code in free() */\n" +
   7224 "          size = p->size & ~PREV_INUSE;\n" +
   7225 "          nextchunk = chunk_at_offset(p, size);\n" +
   7226 "          nextsize = chunksize(nextchunk);\n" +
   7227 "\n" +
   7228 "          if (!prev_inuse(p)) {\n" +
   7229 "            prevsize = p->prev_size;\n" +
   7230 "            size += prevsize;\n" +
   7231 "            p = chunk_at_offset(p, -((long) prevsize));\n" +
   7232 "            unlink(p, bck, fwd);\n" +
   7233 "          }\n" +
   7234 "\n" +
   7235 "          if (nextchunk != av->top) {\n" +
   7236 "            nextinuse = inuse_bit_at_offset(nextchunk, nextsize);\n" +
   7237 "            set_head(nextchunk, nextsize);\n" +
   7238 "\n" +
   7239 "            if (!nextinuse) {\n" +
   7240 "              size += nextsize;\n" +
   7241 "              unlink(nextchunk, bck, fwd);\n" +
   7242 "            }\n" +
   7243 "\n" +
   7244 "            first_unsorted = unsorted_bin->fd;\n" +
   7245 "            unsorted_bin->fd = p;\n" +
   7246 "            first_unsorted->bk = p;\n" +
   7247 "\n" +
   7248 "            set_head(p, size | PREV_INUSE);\n" +
   7249 "            p->bk = unsorted_bin;\n" +
   7250 "            p->fd = first_unsorted;\n" +
   7251 "            set_foot(p, size);\n" +
   7252 "          }\n" +
   7253 "\n" +
   7254 "          else {\n" +
   7255 "            size += nextsize;\n" +
   7256 "            set_head(p, size | PREV_INUSE);\n" +
   7257 "            av->top = p;\n" +
   7258 "          }\n" +
   7259 "\n" +
   7260 "        } while ( (p = nextp) != 0);\n" +
   7261 "\n" +
   7262 "      }\n" +
   7263 "    } while (fb++ != maxfb);\n" +
   7264 "  }\n" +
   7265 "  else {\n" +
   7266 "    malloc_init_state(av);\n" +
   7267 "    check_malloc_state();\n" +
   7268 "  }\n" +
   7269 "}\n" +
   7270 "\n" +
   7271 "/*\n" +
   7272 "  ------------------------------ realloc ------------------------------\n" +
   7273 "*/\n" +
   7274 "\n" +
   7275 "\n" +
   7276 "#if __STD_C\n" +
   7277 "Void_t* rEALLOc(Void_t* oldmem, size_t bytes)\n" +
   7278 "#else\n" +
   7279 "Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;\n" +
   7280 "#endif\n" +
   7281 "{\n" +
   7282 "  mstate av = get_malloc_state();\n" +
   7283 "\n" +
   7284 "  INTERNAL_SIZE_T  nb;              /* padded request size */\n" +
   7285 "\n" +
   7286 "  mchunkptr        oldp;            /* chunk corresponding to oldmem */\n" +
   7287 "  INTERNAL_SIZE_T  oldsize;         /* its size */\n" +
   7288 "\n" +
   7289 "  mchunkptr        newp;            /* chunk to return */\n" +
   7290 "  INTERNAL_SIZE_T  newsize;         /* its size */\n" +
   7291 "  Void_t*          newmem;          /* corresponding user mem */\n" +
   7292 "\n" +
   7293 "  mchunkptr        next;            /* next contiguous chunk after oldp */\n" +
   7294 "\n" +
   7295 "  mchunkptr        remainder;       /* extra space at end of newp */\n" +
   7296 "  CHUNK_SIZE_T     remainder_size;  /* its size */\n" +
   7297 "\n" +
   7298 "  mchunkptr        bck;             /* misc temp for linking */\n" +
   7299 "  mchunkptr        fwd;             /* misc temp for linking */\n" +
   7300 "\n" +
   7301 "  CHUNK_SIZE_T     copysize;        /* bytes to copy */\n" +
   7302 "  unsigned int     ncopies;         /* INTERNAL_SIZE_T words to copy */\n" +
   7303 "  INTERNAL_SIZE_T* s;               /* copy source */\n" +
   7304 "  INTERNAL_SIZE_T* d;               /* copy destination */\n" +
   7305 "\n" +
   7306 "\n" +
   7307 "#ifdef REALLOC_ZERO_BYTES_FREES\n" +
   7308 "  if (bytes == 0) {\n" +
   7309 "    fREe(oldmem);\n" +
   7310 "    return 0;\n" +
   7311 "  }\n" +
   7312 "#endif\n" +
   7313 "\n") +
   7314 (
   7315 "  /* realloc of null is supposed to be same as malloc */\n" +
   7316 "  if (oldmem == 0) return mALLOc(bytes);\n" +
   7317 "\n" +
   7318 "  checked_request2size(bytes, nb);\n" +
   7319 "\n" +
   7320 "  oldp    = mem2chunk(oldmem);\n" +
   7321 "  oldsize = chunksize(oldp);\n" +
   7322 "\n" +
   7323 "  check_inuse_chunk(oldp);\n" +
   7324 "\n" +
   7325 "  if (!chunk_is_mmapped(oldp)) {\n" +
   7326 "\n" +
   7327 "    if ((CHUNK_SIZE_T)(oldsize) >= (CHUNK_SIZE_T)(nb)) {\n" +
   7328 "      /* already big enough; split below */\n" +
   7329 "      newp = oldp;\n" +
   7330 "      newsize = oldsize;\n" +
   7331 "    }\n" +
   7332 "\n" +
   7333 "    else {\n" +
   7334 "      next = chunk_at_offset(oldp, oldsize);\n" +
   7335 "\n" +
   7336 "      /* Try to expand forward into top */\n" +
   7337 "      if (next == av->top &&\n" +
   7338 "          (CHUNK_SIZE_T)(newsize = oldsize + chunksize(next)) >=\n" +
   7339 "          (CHUNK_SIZE_T)(nb + MINSIZE)) {\n" +
   7340 "        set_head_size(oldp, nb);\n" +
   7341 "        av->top = chunk_at_offset(oldp, nb);\n" +
   7342 "        set_head(av->top, (newsize - nb) | PREV_INUSE);\n" +
   7343 "        return chunk2mem(oldp);\n" +
   7344 "      }\n" +
   7345 "\n" +
   7346 "      /* Try to expand forward into next chunk;  split off remainder below */\n" +
   7347 "      else if (next != av->top &&\n" +
   7348 "               !inuse(next) &&\n" +
   7349 "               (CHUNK_SIZE_T)(newsize = oldsize + chunksize(next)) >=\n" +
   7350 "               (CHUNK_SIZE_T)(nb)) {\n" +
   7351 "        newp = oldp;\n" +
   7352 "        unlink(next, bck, fwd);\n" +
   7353 "      }\n" +
   7354 "\n" +
   7355 "      /* allocate, copy, free */\n" +
   7356 "      else {\n" +
   7357 "        newmem = mALLOc(nb - MALLOC_ALIGN_MASK);\n" +
   7358 "        if (newmem == 0)\n" +
   7359 "          return 0; /* propagate failure */\n" +
   7360 "\n" +
   7361 "        newp = mem2chunk(newmem);\n" +
   7362 "        newsize = chunksize(newp);\n" +
   7363 "\n" +
   7364 "        /*\n" +
   7365 "          Avoid copy if newp is next chunk after oldp.\n" +
   7366 "        */\n" +
   7367 "        if (newp == next) {\n" +
   7368 "          newsize += oldsize;\n" +
   7369 "          newp = oldp;\n" +
   7370 "        }\n" +
   7371 "        else {\n" +
   7372 "          /*\n" +
   7373 "            Unroll copy of <= 36 bytes (72 if 8byte sizes)\n" +
   7374 "            We know that contents have an odd number of\n" +
   7375 "            INTERNAL_SIZE_T-sized words; minimally 3.\n" +
   7376 "          */\n" +
   7377 "\n" +
   7378 "          copysize = oldsize - SIZE_SZ;\n" +
   7379 "          s = (INTERNAL_SIZE_T*)(oldmem);\n" +
   7380 "          d = (INTERNAL_SIZE_T*)(newmem);\n" +
   7381 "          ncopies = copysize / sizeof(INTERNAL_SIZE_T);\n" +
   7382 "          assert(ncopies >= 3);\n" +
   7383 "\n" +
   7384 "          if (ncopies > 9)\n" +
   7385 "            MALLOC_COPY(d, s, copysize);\n" +
   7386 "\n" +
   7387 "          else {\n" +
   7388 "            *(d+0) = *(s+0);\n" +
   7389 "            *(d+1) = *(s+1);\n" +
   7390 "            *(d+2) = *(s+2);\n" +
   7391 "            if (ncopies > 4) {\n" +
   7392 "              *(d+3) = *(s+3);\n" +
   7393 "              *(d+4) = *(s+4);\n" +
   7394 "              if (ncopies > 6) {\n" +
   7395 "                *(d+5) = *(s+5);\n" +
   7396 "                *(d+6) = *(s+6);\n" +
   7397 "                if (ncopies > 8) {\n" +
   7398 "                  *(d+7) = *(s+7);\n" +
   7399 "                  *(d+8) = *(s+8);\n" +
   7400 "                }\n" +
   7401 "              }\n" +
   7402 "            }\n" +
   7403 "          }\n" +
   7404 "\n" +
   7405 "          fREe(oldmem);\n" +
   7406 "          check_inuse_chunk(newp);\n" +
   7407 "          return chunk2mem(newp);\n" +
   7408 "        }\n" +
   7409 "      }\n" +
   7410 "    }\n" +
   7411 "\n" +
   7412 "    /* If possible, free extra space in old or extended chunk */\n" +
   7413 "\n" +
   7414 "    assert((CHUNK_SIZE_T)(newsize) >= (CHUNK_SIZE_T)(nb));\n" +
   7415 "\n" +
   7416 "    remainder_size = newsize - nb;\n" +
   7417 "\n" +
   7418 "    if (remainder_size < MINSIZE) { /* not enough extra to split off */\n" +
   7419 "      set_head_size(newp, newsize);\n" +
   7420 "      set_inuse_bit_at_offset(newp, newsize);\n" +
   7421 "    }\n" +
   7422 "    else { /* split remainder */\n" +
   7423 "      remainder = chunk_at_offset(newp, nb);\n" +
   7424 "      set_head_size(newp, nb);\n" +
   7425 "      set_head(remainder, remainder_size | PREV_INUSE);\n" +
   7426 "      /* Mark remainder as inuse so free() won't complain */\n" +
   7427 "      set_inuse_bit_at_offset(remainder, remainder_size);\n" +
   7428 "      fREe(chunk2mem(remainder));\n" +
   7429 "    }\n" +
   7430 "\n" +
   7431 "    check_inuse_chunk(newp);\n" +
   7432 "    return chunk2mem(newp);\n" +
   7433 "  }\n" +
   7434 "\n" +
   7435 "  /*\n" +
   7436 "    Handle mmap cases\n" +
   7437 "  */\n" +
   7438 "\n" +
   7439 "  else {\n" +
   7440 "#if HAVE_MMAP\n" +
   7441 "\n" +
   7442 "#if HAVE_MREMAP\n" +
   7443 "    INTERNAL_SIZE_T offset = oldp->prev_size;\n" +
   7444 "    size_t pagemask = av->pagesize - 1;\n" +
   7445 "    char *cp;\n" +
   7446 "    CHUNK_SIZE_T  sum;\n" +
   7447 "\n" +
   7448 "    /* Note the extra SIZE_SZ overhead */\n" +
   7449 "    newsize = (nb + offset + SIZE_SZ + pagemask) & ~pagemask;\n" +
   7450 "\n" +
   7451 "    /* don't need to remap if still within same page */\n" +
   7452 "    if (oldsize == newsize - offset)\n" +
   7453 "      return oldmem;\n" +
   7454 "\n" +
   7455 "    cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1);\n" +
   7456 "\n" +
   7457 "    if (cp != (char*)MORECORE_FAILURE) {\n" +
   7458 "\n" +
   7459 "      newp = (mchunkptr)(cp + offset);\n" +
   7460 "      set_head(newp, (newsize - offset)|IS_MMAPPED);\n" +
   7461 "\n" +
   7462 "      assert(aligned_OK(chunk2mem(newp)));\n" +
   7463 "      assert((newp->prev_size == offset));\n" +
   7464 "\n") +
   7465 (
   7466 "      /* update statistics */\n" +
   7467 "      sum = av->mmapped_mem += newsize - oldsize;\n" +
   7468 "      if (sum > (CHUNK_SIZE_T)(av->max_mmapped_mem))\n" +
   7469 "        av->max_mmapped_mem = sum;\n" +
   7470 "      sum += av->sbrked_mem;\n" +
   7471 "      if (sum > (CHUNK_SIZE_T)(av->max_total_mem))\n" +
   7472 "        av->max_total_mem = sum;\n" +
   7473 "\n" +
   7474 "      return chunk2mem(newp);\n" +
   7475 "    }\n" +
   7476 "#endif\n" +
   7477 "\n" +
   7478 "    /* Note the extra SIZE_SZ overhead. */\n" +
   7479 "    if ((CHUNK_SIZE_T)(oldsize) >= (CHUNK_SIZE_T)(nb + SIZE_SZ))\n" +
   7480 "      newmem = oldmem; /* do nothing */\n" +
   7481 "    else {\n" +
   7482 "      /* Must alloc, copy, free. */\n" +
   7483 "      newmem = mALLOc(nb - MALLOC_ALIGN_MASK);\n" +
   7484 "      if (newmem != 0) {\n" +
   7485 "        MALLOC_COPY(newmem, oldmem, oldsize - 2*SIZE_SZ);\n" +
   7486 "        fREe(oldmem);\n" +
   7487 "      }\n" +
   7488 "    }\n" +
   7489 "    return newmem;\n" +
   7490 "\n" +
   7491 "#else\n" +
   7492 "    /* If !HAVE_MMAP, but chunk_is_mmapped, user must have overwritten mem */\n" +
   7493 "    check_malloc_state();\n" +
   7494 "    MALLOC_FAILURE_ACTION;\n" +
   7495 "    return 0;\n" +
   7496 "#endif\n" +
   7497 "  }\n" +
   7498 "}\n" +
   7499 "\n" +
   7500 "/*\n" +
   7501 "  ------------------------------ memalign ------------------------------\n" +
   7502 "*/\n" +
   7503 "\n" +
   7504 "#if __STD_C\n" +
   7505 "Void_t* mEMALIGn(size_t alignment, size_t bytes)\n" +
   7506 "#else\n" +
   7507 "Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;\n" +
   7508 "#endif\n" +
   7509 "{\n" +
   7510 "  INTERNAL_SIZE_T nb;             /* padded  request size */\n" +
   7511 "  char*           m;              /* memory returned by malloc call */\n" +
   7512 "  mchunkptr       p;              /* corresponding chunk */\n" +
   7513 "  char*           brk;            /* alignment point within p */\n" +
   7514 "  mchunkptr       newp;           /* chunk to return */\n" +
   7515 "  INTERNAL_SIZE_T newsize;        /* its size */\n" +
   7516 "  INTERNAL_SIZE_T leadsize;       /* leading space before alignment point */\n" +
   7517 "  mchunkptr       remainder;      /* spare room at end to split off */\n" +
   7518 "  CHUNK_SIZE_T    remainder_size; /* its size */\n" +
   7519 "  INTERNAL_SIZE_T size;\n" +
   7520 "\n" +
   7521 "  /* If need less alignment than we give anyway, just relay to malloc */\n" +
   7522 "\n" +
   7523 "  if (alignment <= MALLOC_ALIGNMENT) return mALLOc(bytes);\n" +
   7524 "\n" +
   7525 "  /* Otherwise, ensure that it is at least a minimum chunk size */\n" +
   7526 "\n" +
   7527 "  if (alignment <  MINSIZE) alignment = MINSIZE;\n" +
   7528 "\n" +
   7529 "  /* Make sure alignment is power of 2 (in case MINSIZE is not).  */\n" +
   7530 "  if ((alignment & (alignment - 1)) != 0) {\n" +
   7531 "    size_t a = MALLOC_ALIGNMENT * 2;\n" +
   7532 "    while ((CHUNK_SIZE_T)a < (CHUNK_SIZE_T)alignment) a <<= 1;\n" +
   7533 "    alignment = a;\n" +
   7534 "  }\n" +
   7535 "\n" +
   7536 "  checked_request2size(bytes, nb);\n" +
   7537 "\n" +
   7538 "  /*\n" +
   7539 "    Strategy: find a spot within that chunk that meets the alignment\n" +
   7540 "    request, and then possibly free the leading and trailing space.\n" +
   7541 "  */\n" +
   7542 "\n" +
   7543 "\n" +
   7544 "  /* Call malloc with worst case padding to hit alignment. */\n" +
   7545 "\n" +
   7546 "  m  = (char*)(mALLOc(nb + alignment + MINSIZE));\n" +
   7547 "\n" +
   7548 "  if (m == 0) return 0; /* propagate failure */\n" +
   7549 "\n" +
   7550 "  p = mem2chunk(m);\n" +
   7551 "\n" +
   7552 "  if ((((PTR_UINT)(m)) % alignment) != 0) { /* misaligned */\n" +
   7553 "\n" +
   7554 "    /*\n" +
   7555 "      Find an aligned spot inside chunk.  Since we need to give back\n" +
   7556 "      leading space in a chunk of at least MINSIZE, if the first\n" +
   7557 "      calculation places us at a spot with less than MINSIZE leader,\n" +
   7558 "      we can move to the next aligned spot -- we've allocated enough\n" +
   7559 "      total room so that this is always possible.\n" +
   7560 "    */\n" +
   7561 "\n" +
   7562 "    brk = (char*)mem2chunk((PTR_UINT)(((PTR_UINT)(m + alignment - 1)) &\n" +
   7563 "                           -((signed long) alignment)));\n" +
   7564 "    if ((CHUNK_SIZE_T)(brk - (char*)(p)) < MINSIZE)\n" +
   7565 "      brk += alignment;\n" +
   7566 "\n" +
   7567 "    newp = (mchunkptr)brk;\n" +
   7568 "    leadsize = brk - (char*)(p);\n" +
   7569 "    newsize = chunksize(p) - leadsize;\n" +
   7570 "\n" +
   7571 "    /* For mmapped chunks, just adjust offset */\n" +
   7572 "    if (chunk_is_mmapped(p)) {\n" +
   7573 "      newp->prev_size = p->prev_size + leadsize;\n" +
   7574 "      set_head(newp, newsize|IS_MMAPPED);\n" +
   7575 "      return chunk2mem(newp);\n" +
   7576 "    }\n" +
   7577 "\n" +
   7578 "    /* Otherwise, give back leader, use the rest */\n" +
   7579 "    set_head(newp, newsize | PREV_INUSE);\n" +
   7580 "    set_inuse_bit_at_offset(newp, newsize);\n" +
   7581 "    set_head_size(p, leadsize);\n" +
   7582 "    fREe(chunk2mem(p));\n" +
   7583 "    p = newp;\n" +
   7584 "\n" +
   7585 "    assert (newsize >= nb &&\n" +
   7586 "            (((PTR_UINT)(chunk2mem(p))) % alignment) == 0);\n" +
   7587 "  }\n" +
   7588 "\n" +
   7589 "  /* Also give back spare room at the end */\n" +
   7590 "  if (!chunk_is_mmapped(p)) {\n" +
   7591 "    size = chunksize(p);\n" +
   7592 "    if ((CHUNK_SIZE_T)(size) > (CHUNK_SIZE_T)(nb + MINSIZE)) {\n" +
   7593 "      remainder_size = size - nb;\n" +
   7594 "      remainder = chunk_at_offset(p, nb);\n" +
   7595 "      set_head(remainder, remainder_size | PREV_INUSE);\n" +
   7596 "      set_head_size(p, nb);\n" +
   7597 "      fREe(chunk2mem(remainder));\n" +
   7598 "    }\n" +
   7599 "  }\n" +
   7600 "\n" +
   7601 "  check_inuse_chunk(p);\n" +
   7602 "  return chunk2mem(p);\n" +
   7603 "}\n" +
   7604 "\n" +
   7605 "/*\n" +
   7606 "  ------------------------------ calloc ------------------------------\n" +
   7607 "*/\n" +
   7608 "\n" +
   7609 "#if __STD_C\n" +
   7610 "Void_t* cALLOc(size_t n_elements, size_t elem_size)\n" +
   7611 "#else\n" +
   7612 "Void_t* cALLOc(n_elements, elem_size) size_t n_elements; size_t elem_size;\n" +
   7613 "#endif\n" +
   7614 "{\n" +
   7615 "  mchunkptr p;\n" +
   7616 "  CHUNK_SIZE_T  clearsize;\n" +
   7617 "  CHUNK_SIZE_T  nclears;\n" +
   7618 "  INTERNAL_SIZE_T* d;\n" +
   7619 "\n") +
   7620 (
   7621 "  Void_t* mem = mALLOc(n_elements * elem_size);\n" +
   7622 "\n" +
   7623 "  if (mem != 0) {\n" +
   7624 "    p = mem2chunk(mem);\n" +
   7625 "\n" +
   7626 "    if (!chunk_is_mmapped(p))\n" +
   7627 "    {\n" +
   7628 "      /*\n" +
   7629 "        Unroll clear of <= 36 bytes (72 if 8byte sizes)\n" +
   7630 "        We know that contents have an odd number of\n" +
   7631 "        INTERNAL_SIZE_T-sized words; minimally 3.\n" +
   7632 "      */\n" +
   7633 "\n" +
   7634 "      d = (INTERNAL_SIZE_T*)mem;\n" +
   7635 "      clearsize = chunksize(p) - SIZE_SZ;\n" +
   7636 "      nclears = clearsize / sizeof(INTERNAL_SIZE_T);\n" +
   7637 "      assert(nclears >= 3);\n" +
   7638 "\n" +
   7639 "      if (nclears > 9)\n" +
   7640 "        MALLOC_ZERO(d, clearsize);\n" +
   7641 "\n" +
   7642 "      else {\n" +
   7643 "        *(d+0) = 0;\n" +
   7644 "        *(d+1) = 0;\n" +
   7645 "        *(d+2) = 0;\n" +
   7646 "        if (nclears > 4) {\n" +
   7647 "          *(d+3) = 0;\n" +
   7648 "          *(d+4) = 0;\n" +
   7649 "          if (nclears > 6) {\n" +
   7650 "            *(d+5) = 0;\n" +
   7651 "            *(d+6) = 0;\n" +
   7652 "            if (nclears > 8) {\n" +
   7653 "              *(d+7) = 0;\n" +
   7654 "              *(d+8) = 0;\n" +
   7655 "            }\n" +
   7656 "          }\n" +
   7657 "        }\n" +
   7658 "      }\n" +
   7659 "    }\n" +
   7660 "#if ! MMAP_CLEARS\n" +
   7661 "    else\n" +
   7662 "    {\n" +
   7663 "      d = (INTERNAL_SIZE_T*)mem;\n" +
   7664 "      /*\n" +
   7665 "        Note the additional SIZE_SZ\n" +
   7666 "      */\n" +
   7667 "      clearsize = chunksize(p) - 2*SIZE_SZ;\n" +
   7668 "      MALLOC_ZERO(d, clearsize);\n" +
   7669 "    }\n" +
   7670 "#endif\n" +
   7671 "  }\n" +
   7672 "  return mem;\n" +
   7673 "}\n" +
   7674 "\n" +
   7675 "/*\n" +
   7676 "  ------------------------------ cfree ------------------------------\n" +
   7677 "*/\n" +
   7678 "\n" +
   7679 "#if __STD_C\n" +
   7680 "void cFREe(Void_t *mem)\n" +
   7681 "#else\n" +
   7682 "void cFREe(mem) Void_t *mem;\n" +
   7683 "#endif\n" +
   7684 "{\n" +
   7685 "  fREe(mem);\n" +
   7686 "}\n" +
   7687 "\n" +
   7688 "/*\n" +
   7689 "  ------------------------- independent_calloc -------------------------\n" +
   7690 "*/\n" +
   7691 "\n" +
   7692 "#if __STD_C\n" +
   7693 "Void_t** iCALLOc(size_t n_elements, size_t elem_size, Void_t* chunks[])\n" +
   7694 "#else\n" +
   7695 "Void_t** iCALLOc(n_elements, elem_size, chunks) size_t n_elements; size_t elem_size; Void_t* chunks[];\n" +
   7696 "#endif\n" +
   7697 "{\n" +
   7698 "  size_t sz = elem_size; /* serves as 1-element array */\n" +
   7699 "  /* opts arg of 3 means all elements are same size, and should be cleared */\n" +
   7700 "  return iALLOc(n_elements, &sz, 3, chunks);\n" +
   7701 "}\n" +
   7702 "\n" +
   7703 "/*\n" +
   7704 "  ------------------------- independent_comalloc -------------------------\n" +
   7705 "*/\n" +
   7706 "\n" +
   7707 "#if __STD_C\n" +
   7708 "Void_t** iCOMALLOc(size_t n_elements, size_t sizes[], Void_t* chunks[])\n" +
   7709 "#else\n" +
   7710 "Void_t** iCOMALLOc(n_elements, sizes, chunks) size_t n_elements; size_t sizes[]; Void_t* chunks[];\n" +
   7711 "#endif\n" +
   7712 "{\n" +
   7713 "  return iALLOc(n_elements, sizes, 0, chunks);\n" +
   7714 "}\n" +
   7715 "\n" +
   7716 "\n" +
   7717 "/*\n" +
   7718 "  ------------------------------ ialloc ------------------------------\n" +
   7719 "  ialloc provides common support for independent_X routines, handling all of\n" +
   7720 "  the combinations that can result.\n" +
   7721 "\n" +
   7722 "  The opts arg has:\n" +
   7723 "    bit 0 set if all elements are same size (using sizes[0])\n" +
   7724 "    bit 1 set if elements should be zeroed\n" +
   7725 "*/\n" +
   7726 "\n" +
   7727 "\n" +
   7728 "#if __STD_C\n" +
   7729 "static Void_t** iALLOc(size_t n_elements,\n" +
   7730 "                       size_t* sizes,\n" +
   7731 "                       int opts,\n" +
   7732 "                       Void_t* chunks[])\n" +
   7733 "#else\n" +
   7734 "static Void_t** iALLOc(n_elements, sizes, opts, chunks) size_t n_elements; size_t* sizes; int opts; Void_t* chunks[];\n" +
   7735 "#endif\n" +
   7736 "{\n" +
   7737 "  mstate av = get_malloc_state();\n" +
   7738 "  INTERNAL_SIZE_T element_size;   /* chunksize of each element, if all same */\n" +
   7739 "  INTERNAL_SIZE_T contents_size;  /* total size of elements */\n" +
   7740 "  INTERNAL_SIZE_T array_size;     /* request size of pointer array */\n" +
   7741 "  Void_t*         mem;            /* malloced aggregate space */\n" +
   7742 "  mchunkptr       p;              /* corresponding chunk */\n" +
   7743 "  INTERNAL_SIZE_T remainder_size; /* remaining bytes while splitting */\n" +
   7744 "  Void_t**        marray;         /* either \"chunks\" or malloced ptr array */\n" +
   7745 "  mchunkptr       array_chunk;    /* chunk for malloced ptr array */\n" +
   7746 "  int             mmx;            /* to disable mmap */\n" +
   7747 "  INTERNAL_SIZE_T size;\n" +
   7748 "  size_t          i;\n" +
   7749 "\n" +
   7750 "  /* Ensure initialization */\n" +
   7751 "  if (av->max_fast == 0) malloc_consolidate(av);\n" +
   7752 "\n" +
   7753 "  /* compute array length, if needed */\n" +
   7754 "  if (chunks != 0) {\n" +
   7755 "    if (n_elements == 0)\n" +
   7756 "      return chunks; /* nothing to do */\n" +
   7757 "    marray = chunks;\n" +
   7758 "    array_size = 0;\n" +
   7759 "  }\n" +
   7760 "  else {\n" +
   7761 "    /* if empty req, must still return chunk representing empty array */\n" +
   7762 "    if (n_elements == 0)\n" +
   7763 "      return (Void_t**) mALLOc(0);\n" +
   7764 "    marray = 0;\n" +
   7765 "    array_size = request2size(n_elements * (sizeof(Void_t*)));\n" +
   7766 "  }\n" +
   7767 "\n" +
   7768 "  /* compute total element size */\n" +
   7769 "  if (opts & 0x1) { /* all-same-size */\n" +
   7770 "    element_size = request2size(*sizes);\n" +
   7771 "    contents_size = n_elements * element_size;\n" +
   7772 "  }\n" +
   7773 "  else { /* add up all the sizes */\n" +
   7774 "    element_size = 0;\n" +
   7775 "    contents_size = 0;\n" +
   7776 "    for (i = 0; i != n_elements; ++i)\n" +
   7777 "      contents_size += request2size(sizes[i]);\n" +
   7778 "  }\n" +
   7779 "\n") +
   7780 (
   7781 "  /* subtract out alignment bytes from total to minimize overallocation */\n" +
   7782 "  size = contents_size + array_size - MALLOC_ALIGN_MASK;\n" +
   7783 "\n" +
   7784 "  /*\n" +
   7785 "     Allocate the aggregate chunk.\n" +
   7786 "     But first disable mmap so malloc won't use it, since\n" +
   7787 "     we would not be able to later free/realloc space internal\n" +
   7788 "     to a segregated mmap region.\n" +
   7789 " */\n" +
   7790 "  mmx = av->n_mmaps_max;   /* disable mmap */\n" +
   7791 "  av->n_mmaps_max = 0;\n" +
   7792 "  mem = mALLOc(size);\n" +
   7793 "  av->n_mmaps_max = mmx;   /* reset mmap */\n" +
   7794 "  if (mem == 0)\n" +
   7795 "    return 0;\n" +
   7796 "\n" +
   7797 "  p = mem2chunk(mem);\n" +
   7798 "  assert(!chunk_is_mmapped(p));\n" +
   7799 "  remainder_size = chunksize(p);\n" +
   7800 "\n" +
   7801 "  if (opts & 0x2) {       /* optionally clear the elements */\n" +
   7802 "    MALLOC_ZERO(mem, remainder_size - SIZE_SZ - array_size);\n" +
   7803 "  }\n" +
   7804 "\n" +
   7805 "  /* If not provided, allocate the pointer array as final part of chunk */\n" +
   7806 "  if (marray == 0) {\n" +
   7807 "    array_chunk = chunk_at_offset(p, contents_size);\n" +
   7808 "    marray = (Void_t**) (chunk2mem(array_chunk));\n" +
   7809 "    set_head(array_chunk, (remainder_size - contents_size) | PREV_INUSE);\n" +
   7810 "    remainder_size = contents_size;\n" +
   7811 "  }\n" +
   7812 "\n" +
   7813 "  /* split out elements */\n" +
   7814 "  for (i = 0; ; ++i) {\n" +
   7815 "    marray[i] = chunk2mem(p);\n" +
   7816 "    if (i != n_elements-1) {\n" +
   7817 "      if (element_size != 0)\n" +
   7818 "        size = element_size;\n" +
   7819 "      else\n" +
   7820 "        size = request2size(sizes[i]);\n" +
   7821 "      remainder_size -= size;\n" +
   7822 "      set_head(p, size | PREV_INUSE);\n" +
   7823 "      p = chunk_at_offset(p, size);\n" +
   7824 "    }\n" +
   7825 "    else { /* the final element absorbs any overallocation slop */\n" +
   7826 "      set_head(p, remainder_size | PREV_INUSE);\n" +
   7827 "      break;\n" +
   7828 "    }\n" +
   7829 "  }\n" +
   7830 "\n" +
   7831 "#if DEBUG\n" +
   7832 "  if (marray != chunks) {\n" +
   7833 "    /* final element must have exactly exhausted chunk */\n" +
   7834 "    if (element_size != 0)\n" +
   7835 "      assert(remainder_size == element_size);\n" +
   7836 "    else\n" +
   7837 "      assert(remainder_size == request2size(sizes[i]));\n" +
   7838 "    check_inuse_chunk(mem2chunk(marray));\n" +
   7839 "  }\n" +
   7840 "\n" +
   7841 "  for (i = 0; i != n_elements; ++i)\n" +
   7842 "    check_inuse_chunk(mem2chunk(marray[i]));\n" +
   7843 "#endif\n" +
   7844 "\n" +
   7845 "  return marray;\n" +
   7846 "}\n" +
   7847 "\n" +
   7848 "\n" +
   7849 "/*\n" +
   7850 "  ------------------------------ valloc ------------------------------\n" +
   7851 "*/\n" +
   7852 "\n" +
   7853 "#if __STD_C\n" +
   7854 "Void_t* vALLOc(size_t bytes)\n" +
   7855 "#else\n" +
   7856 "Void_t* vALLOc(bytes) size_t bytes;\n" +
   7857 "#endif\n" +
   7858 "{\n" +
   7859 "  /* Ensure initialization */\n" +
   7860 "  mstate av = get_malloc_state();\n" +
   7861 "  if (av->max_fast == 0) malloc_consolidate(av);\n" +
   7862 "  return mEMALIGn(av->pagesize, bytes);\n" +
   7863 "}\n" +
   7864 "\n" +
   7865 "/*\n" +
   7866 "  ------------------------------ pvalloc ------------------------------\n" +
   7867 "*/\n" +
   7868 "\n" +
   7869 "\n" +
   7870 "#if __STD_C\n" +
   7871 "Void_t* pVALLOc(size_t bytes)\n" +
   7872 "#else\n" +
   7873 "Void_t* pVALLOc(bytes) size_t bytes;\n" +
   7874 "#endif\n" +
   7875 "{\n" +
   7876 "  mstate av = get_malloc_state();\n" +
   7877 "  size_t pagesz;\n" +
   7878 "\n" +
   7879 "  /* Ensure initialization */\n" +
   7880 "  if (av->max_fast == 0) malloc_consolidate(av);\n" +
   7881 "  pagesz = av->pagesize;\n" +
   7882 "  return mEMALIGn(pagesz, (bytes + pagesz - 1) & ~(pagesz - 1));\n" +
   7883 "}\n" +
   7884 "\n" +
   7885 "\n" +
   7886 "/*\n" +
   7887 "  ------------------------------ malloc_trim ------------------------------\n" +
   7888 "*/\n" +
   7889 "\n" +
   7890 "#if __STD_C\n" +
   7891 "int mTRIm(size_t pad)\n" +
   7892 "#else\n" +
   7893 "int mTRIm(pad) size_t pad;\n" +
   7894 "#endif\n" +
   7895 "{\n" +
   7896 "  mstate av = get_malloc_state();\n" +
   7897 "  /* Ensure initialization/consolidation */\n" +
   7898 "  malloc_consolidate(av);\n" +
   7899 "\n" +
   7900 "#ifndef MORECORE_CANNOT_TRIM\n" +
   7901 "  return sYSTRIm(pad, av);\n" +
   7902 "#else\n" +
   7903 "  return 0;\n" +
   7904 "#endif\n" +
   7905 "}\n" +
   7906 "\n" +
   7907 "\n" +
   7908 "/*\n" +
   7909 "  ------------------------- malloc_usable_size -------------------------\n" +
   7910 "*/\n" +
   7911 "\n" +
   7912 "#if __STD_C\n" +
   7913 "size_t mUSABLe(Void_t* mem)\n" +
   7914 "#else\n" +
   7915 "size_t mUSABLe(mem) Void_t* mem;\n" +
   7916 "#endif\n" +
   7917 "{\n" +
   7918 "  mchunkptr p;\n" +
   7919 "  if (mem != 0) {\n" +
   7920 "    p = mem2chunk(mem);\n" +
   7921 "    if (chunk_is_mmapped(p))\n" +
   7922 "      return chunksize(p) - 2*SIZE_SZ;\n" +
   7923 "    else if (inuse(p))\n" +
   7924 "      return chunksize(p) - SIZE_SZ;\n" +
   7925 "  }\n" +
   7926 "  return 0;\n" +
   7927 "}\n" +
   7928 "\n" +
   7929 "/*\n" +
   7930 "  ------------------------------ mallinfo ------------------------------\n" +
   7931 "*/\n" +
   7932 "\n") +
   7933 (
   7934 "struct mallinfo mALLINFo()\n" +
   7935 "{\n" +
   7936 "  mstate av = get_malloc_state();\n" +
   7937 "  struct mallinfo mi;\n" +
   7938 "  unsigned int i;\n" +
   7939 "  mbinptr b;\n" +
   7940 "  mchunkptr p;\n" +
   7941 "  INTERNAL_SIZE_T avail;\n" +
   7942 "  INTERNAL_SIZE_T fastavail;\n" +
   7943 "  int nblocks;\n" +
   7944 "  int nfastblocks;\n" +
   7945 "\n" +
   7946 "  /* Ensure initialization */\n" +
   7947 "  if (av->top == 0)  malloc_consolidate(av);\n" +
   7948 "\n" +
   7949 "  check_malloc_state();\n" +
   7950 "\n" +
   7951 "  /* Account for top */\n" +
   7952 "  avail = chunksize(av->top);\n" +
   7953 "  nblocks = 1;  /* top always exists */\n" +
   7954 "\n" +
   7955 "  /* traverse fastbins */\n" +
   7956 "  nfastblocks = 0;\n" +
   7957 "  fastavail = 0;\n" +
   7958 "\n" +
   7959 "  for (i = 0; i < NFASTBINS; ++i) {\n" +
   7960 "    for (p = av->fastbins[i]; p != 0; p = p->fd) {\n" +
   7961 "      ++nfastblocks;\n" +
   7962 "      fastavail += chunksize(p);\n" +
   7963 "    }\n" +
   7964 "  }\n" +
   7965 "\n" +
   7966 "  avail += fastavail;\n" +
   7967 "\n" +
   7968 "  /* traverse regular bins */\n" +
   7969 "  for (i = 1; i < NBINS; ++i) {\n" +
   7970 "    b = bin_at(av, i);\n" +
   7971 "    for (p = last(b); p != b; p = p->bk) {\n" +
   7972 "      ++nblocks;\n" +
   7973 "      avail += chunksize(p);\n" +
   7974 "    }\n" +
   7975 "  }\n" +
   7976 "\n" +
   7977 "  mi.smblks = nfastblocks;\n" +
   7978 "  mi.ordblks = nblocks;\n" +
   7979 "  mi.fordblks = avail;\n" +
   7980 "  mi.uordblks = av->sbrked_mem - avail;\n" +
   7981 "  mi.arena = av->sbrked_mem;\n" +
   7982 "  mi.hblks = av->n_mmaps;\n" +
   7983 "  mi.hblkhd = av->mmapped_mem;\n" +
   7984 "  mi.fsmblks = fastavail;\n" +
   7985 "  mi.keepcost = chunksize(av->top);\n" +
   7986 "  mi.usmblks = av->max_total_mem;\n" +
   7987 "  return mi;\n" +
   7988 "}\n" +
   7989 "\n" +
   7990 "/*\n" +
   7991 "  ------------------------------ malloc_stats ------------------------------\n" +
   7992 "*/\n" +
   7993 "\n" +
   7994 "void mSTATs()\n" +
   7995 "{\n" +
   7996 "  struct mallinfo mi = mALLINFo();\n" +
   7997 "\n" +
   7998 "#ifdef WIN32\n" +
   7999 "  {\n" +
   8000 "    CHUNK_SIZE_T  free, reserved, committed;\n" +
   8001 "    vminfo (&free, &reserved, &committed);\n" +
   8002 "    fprintf(stderr, \"free bytes       = %10lu\\n\",\n" +
   8003 "            free);\n" +
   8004 "    fprintf(stderr, \"reserved bytes   = %10lu\\n\",\n" +
   8005 "            reserved);\n" +
   8006 "    fprintf(stderr, \"committed bytes  = %10lu\\n\",\n" +
   8007 "            committed);\n" +
   8008 "  }\n" +
   8009 "#endif\n" +
   8010 "\n" +
   8011 "\n" +
   8012 "  fprintf(stderr, \"max system bytes = %10lu\\n\",\n" +
   8013 "          (CHUNK_SIZE_T)(mi.usmblks));\n" +
   8014 "  fprintf(stderr, \"system bytes     = %10lu\\n\",\n" +
   8015 "          (CHUNK_SIZE_T)(mi.arena + mi.hblkhd));\n" +
   8016 "  fprintf(stderr, \"in use bytes     = %10lu\\n\",\n" +
   8017 "          (CHUNK_SIZE_T)(mi.uordblks + mi.hblkhd));\n" +
   8018 "\n" +
   8019 "#ifdef WIN32\n" +
   8020 "  {\n" +
   8021 "    CHUNK_SIZE_T  kernel, user;\n" +
   8022 "    if (cpuinfo (TRUE, &kernel, &user)) {\n" +
   8023 "      fprintf(stderr, \"kernel ms        = %10lu\\n\",\n" +
   8024 "              kernel);\n" +
   8025 "      fprintf(stderr, \"user ms          = %10lu\\n\",\n" +
   8026 "              user);\n" +
   8027 "    }\n" +
   8028 "  }\n" +
   8029 "#endif\n" +
   8030 "}\n" +
   8031 "\n" +
   8032 "\n" +
   8033 "/*\n" +
   8034 "  ------------------------------ mallopt ------------------------------\n" +
   8035 "*/\n" +
   8036 "\n" +
   8037 "#if __STD_C\n" +
   8038 "int mALLOPt(int param_number, int value)\n" +
   8039 "#else\n" +
   8040 "int mALLOPt(param_number, value) int param_number; int value;\n" +
   8041 "#endif\n" +
   8042 "{\n" +
   8043 "  mstate av = get_malloc_state();\n" +
   8044 "  /* Ensure initialization/consolidation */\n" +
   8045 "  malloc_consolidate(av);\n" +
   8046 "\n" +
   8047 "  switch(param_number) {\n" +
   8048 "  case M_MXFAST:\n" +
   8049 "    if (value >= 0 && value <= MAX_FAST_SIZE) {\n" +
   8050 "      set_max_fast(av, value);\n" +
   8051 "      return 1;\n" +
   8052 "    }\n" +
   8053 "    else\n" +
   8054 "      return 0;\n" +
   8055 "\n" +
   8056 "  case M_TRIM_THRESHOLD:\n" +
   8057 "    av->trim_threshold = value;\n" +
   8058 "    return 1;\n" +
   8059 "\n" +
   8060 "  case M_TOP_PAD:\n" +
   8061 "    av->top_pad = value;\n" +
   8062 "    return 1;\n" +
   8063 "\n" +
   8064 "  case M_MMAP_THRESHOLD:\n" +
   8065 "    av->mmap_threshold = value;\n" +
   8066 "    return 1;\n" +
   8067 "\n" +
   8068 "  case M_MMAP_MAX:\n" +
   8069 "#if !HAVE_MMAP\n" +
   8070 "    if (value != 0)\n" +
   8071 "      return 0;\n" +
   8072 "#endif\n" +
   8073 "    av->n_mmaps_max = value;\n" +
   8074 "    return 1;\n" +
   8075 "\n" +
   8076 "  default:\n" +
   8077 "    return 0;\n" +
   8078 "  }\n" +
   8079 "}\n" +
   8080 "\n" +
   8081 "\n" +
   8082 "/*\n" +
   8083 "  -------------------- Alternative MORECORE functions --------------------\n" +
   8084 "*/\n" +
   8085 "\n") +
   8086 (
   8087 "\n" +
   8088 "/*\n" +
   8089 "  General Requirements for MORECORE.\n" +
   8090 "\n" +
   8091 "  The MORECORE function must have the following properties:\n" +
   8092 "\n" +
   8093 "  If MORECORE_CONTIGUOUS is false:\n" +
   8094 "\n" +
   8095 "    * MORECORE must allocate in multiples of pagesize. It will\n" +
   8096 "      only be called with arguments that are multiples of pagesize.\n" +
   8097 "\n" +
   8098 "    * MORECORE(0) must return an address that is at least\n" +
   8099 "      MALLOC_ALIGNMENT aligned. (Page-aligning always suffices.)\n" +
   8100 "\n" +
   8101 "  else (i.e. If MORECORE_CONTIGUOUS is true):\n" +
   8102 "\n" +
   8103 "    * Consecutive calls to MORECORE with positive arguments\n" +
   8104 "      return increasing addresses, indicating that space has been\n" +
   8105 "      contiguously extended.\n" +
   8106 "\n" +
   8107 "    * MORECORE need not allocate in multiples of pagesize.\n" +
   8108 "      Calls to MORECORE need not have args of multiples of pagesize.\n" +
   8109 "\n" +
   8110 "    * MORECORE need not page-align.\n" +
   8111 "\n" +
   8112 "  In either case:\n" +
   8113 "\n" +
   8114 "    * MORECORE may allocate more memory than requested. (Or even less,\n" +
   8115 "      but this will generally result in a malloc failure.)\n" +
   8116 "\n" +
   8117 "    * MORECORE must not allocate memory when given argument zero, but\n" +
   8118 "      instead return one past the end address of memory from previous\n" +
   8119 "      nonzero call. This malloc does NOT call MORECORE(0)\n" +
   8120 "      until at least one call with positive arguments is made, so\n" +
   8121 "      the initial value returned is not important.\n" +
   8122 "\n" +
   8123 "    * Even though consecutive calls to MORECORE need not return contiguous\n" +
   8124 "      addresses, it must be OK for malloc'ed chunks to span multiple\n" +
   8125 "      regions in those cases where they do happen to be contiguous.\n" +
   8126 "\n" +
   8127 "    * MORECORE need not handle negative arguments -- it may instead\n" +
   8128 "      just return MORECORE_FAILURE when given negative arguments.\n" +
   8129 "      Negative arguments are always multiples of pagesize. MORECORE\n" +
   8130 "      must not misinterpret negative args as large positive unsigned\n" +
   8131 "      args. You can suppress all such calls from even occurring by defining\n" +
   8132 "      MORECORE_CANNOT_TRIM,\n" +
   8133 "\n" +
   8134 "  There is some variation across systems about the type of the\n" +
   8135 "  argument to sbrk/MORECORE. If size_t is unsigned, then it cannot\n" +
   8136 "  actually be size_t, because sbrk supports negative args, so it is\n" +
   8137 "  normally the signed type of the same width as size_t (sometimes\n" +
   8138 "  declared as \"intptr_t\", and sometimes \"ptrdiff_t\").  It doesn't much\n" +
   8139 "  matter though. Internally, we use \"long\" as arguments, which should\n" +
   8140 "  work across all reasonable possibilities.\n" +
   8141 "\n" +
   8142 "  Additionally, if MORECORE ever returns failure for a positive\n" +
   8143 "  request, and HAVE_MMAP is true, then mmap is used as a noncontiguous\n" +
   8144 "  system allocator. This is a useful backup strategy for systems with\n" +
   8145 "  holes in address spaces -- in this case sbrk cannot contiguously\n" +
   8146 "  expand the heap, but mmap may be able to map noncontiguous space.\n" +
   8147 "\n" +
   8148 "  If you'd like mmap to ALWAYS be used, you can define MORECORE to be\n" +
   8149 "  a function that always returns MORECORE_FAILURE.\n" +
   8150 "\n" +
   8151 "  Malloc only has limited ability to detect failures of MORECORE\n" +
   8152 "  to supply contiguous space when it says it can. In particular,\n" +
   8153 "  multithreaded programs that do not use locks may result in\n" +
   8154 "  rece conditions across calls to MORECORE that result in gaps\n" +
   8155 "  that cannot be detected as such, and subsequent corruption.\n" +
   8156 "\n" +
   8157 "  If you are using this malloc with something other than sbrk (or its\n" +
   8158 "  emulation) to supply memory regions, you probably want to set\n" +
   8159 "  MORECORE_CONTIGUOUS as false.  As an example, here is a custom\n" +
   8160 "  allocator kindly contributed for pre-OSX macOS.  It uses virtually\n" +
   8161 "  but not necessarily physically contiguous non-paged memory (locked\n" +
   8162 "  in, present and won't get swapped out).  You can use it by\n" +
   8163 "  uncommenting this section, adding some #includes, and setting up the\n" +
   8164 "  appropriate defines above:\n" +
   8165 "\n" +
   8166 "      #define MORECORE osMoreCore\n" +
   8167 "      #define MORECORE_CONTIGUOUS 0\n" +
   8168 "\n" +
   8169 "  There is also a shutdown routine that should somehow be called for\n" +
   8170 "  cleanup upon program exit.\n" +
   8171 "\n" +
   8172 "  #define MAX_POOL_ENTRIES 100\n" +
   8173 "  #define MINIMUM_MORECORE_SIZE  (64 * 1024)\n" +
   8174 "  static int next_os_pool;\n" +
   8175 "  void *our_os_pools[MAX_POOL_ENTRIES];\n" +
   8176 "\n" +
   8177 "  void *osMoreCore(int size)\n" +
   8178 "  {\n" +
   8179 "    void *ptr = 0;\n" +
   8180 "    static void *sbrk_top = 0;\n" +
   8181 "\n" +
   8182 "    if (size > 0)\n" +
   8183 "    {\n" +
   8184 "      if (size < MINIMUM_MORECORE_SIZE)\n" +
   8185 "         size = MINIMUM_MORECORE_SIZE;\n" +
   8186 "      if (CurrentExecutionLevel() == kTaskLevel)\n" +
   8187 "         ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0);\n" +
   8188 "      if (ptr == 0)\n" +
   8189 "      {\n" +
   8190 "        return (void *) MORECORE_FAILURE;\n" +
   8191 "      }\n" +
   8192 "      // save ptrs so they can be freed during cleanup\n" +
   8193 "      our_os_pools[next_os_pool] = ptr;\n" +
   8194 "      next_os_pool++;\n" +
   8195 "      ptr = (void *) ((((CHUNK_SIZE_T) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK);\n" +
   8196 "      sbrk_top = (char *) ptr + size;\n" +
   8197 "      return ptr;\n" +
   8198 "    }\n" +
   8199 "    else if (size < 0)\n" +
   8200 "    {\n" +
   8201 "      // we don't currently support shrink behavior\n" +
   8202 "      return (void *) MORECORE_FAILURE;\n" +
   8203 "    }\n" +
   8204 "    else\n" +
   8205 "    {\n" +
   8206 "      return sbrk_top;\n" +
   8207 "    }\n" +
   8208 "  }\n" +
   8209 "\n" +
   8210 "  // cleanup any allocated memory pools\n" +
   8211 "  // called as last thing before shutting down driver\n" +
   8212 "\n" +
   8213 "  void osCleanupMem(void)\n" +
   8214 "  {\n" +
   8215 "    void **ptr;\n" +
   8216 "\n" +
   8217 "    for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++)\n" +
   8218 "      if (*ptr)\n" +
   8219 "      {\n" +
   8220 "         PoolDeallocate(*ptr);\n" +
   8221 "         *ptr = 0;\n" +
   8222 "      }\n" +
   8223 "  }\n" +
   8224 "\n" +
   8225 "*/\n" +
   8226 "\n" +
   8227 "\n" +
   8228 "/*\n" +
   8229 "  --------------------------------------------------------------\n" +
   8230 "\n" +
   8231 "  Emulation of sbrk for win32.\n" +
   8232 "  Donated by J. Walter <Walter (a] GeNeSys-e.de>.\n" +
   8233 "  For additional information about this code, and malloc on Win32, see\n" +
   8234 "     http://www.genesys-e.de/jwalter/\n" +
   8235 "*/\n" +
   8236 "\n" +
   8237 "\n") +
   8238 (
   8239 "#ifdef WIN32\n" +
   8240 "\n" +
   8241 "#ifdef _DEBUG\n" +
   8242 "/* #define TRACE */\n" +
   8243 "#endif\n" +
   8244 "\n" +
   8245 "/* Support for USE_MALLOC_LOCK */\n" +
   8246 "#ifdef USE_MALLOC_LOCK\n" +
   8247 "\n" +
   8248 "/* Wait for spin lock */\n" +
   8249 "static int slwait (int *sl) {\n" +
   8250 "    while (InterlockedCompareExchange ((void **) sl, (void *) 1, (void *) 0) != 0)\n" +
   8251 "        Sleep (0);\n" +
   8252 "    return 0;\n" +
   8253 "}\n" +
   8254 "\n" +
   8255 "/* Release spin lock */\n" +
   8256 "static int slrelease (int *sl) {\n" +
   8257 "    InterlockedExchange (sl, 0);\n" +
   8258 "    return 0;\n" +
   8259 "}\n" +
   8260 "\n" +
   8261 "#ifdef NEEDED\n" +
   8262 "/* Spin lock for emulation code */\n" +
   8263 "static int g_sl;\n" +
   8264 "#endif\n" +
   8265 "\n" +
   8266 "#endif /* USE_MALLOC_LOCK */\n" +
   8267 "\n" +
   8268 "/* getpagesize for windows */\n" +
   8269 "static long getpagesize (void) {\n" +
   8270 "    static long g_pagesize = 0;\n" +
   8271 "    if (! g_pagesize) {\n" +
   8272 "        SYSTEM_INFO system_info;\n" +
   8273 "        GetSystemInfo (&system_info);\n" +
   8274 "        g_pagesize = system_info.dwPageSize;\n" +
   8275 "    }\n" +
   8276 "    return g_pagesize;\n" +
   8277 "}\n" +
   8278 "static long getregionsize (void) {\n" +
   8279 "    static long g_regionsize = 0;\n" +
   8280 "    if (! g_regionsize) {\n" +
   8281 "        SYSTEM_INFO system_info;\n" +
   8282 "        GetSystemInfo (&system_info);\n" +
   8283 "        g_regionsize = system_info.dwAllocationGranularity;\n" +
   8284 "    }\n" +
   8285 "    return g_regionsize;\n" +
   8286 "}\n" +
   8287 "\n" +
   8288 "/* A region list entry */\n" +
   8289 "typedef struct _region_list_entry {\n" +
   8290 "    void *top_allocated;\n" +
   8291 "    void *top_committed;\n" +
   8292 "    void *top_reserved;\n" +
   8293 "    long reserve_size;\n" +
   8294 "    struct _region_list_entry *previous;\n" +
   8295 "} region_list_entry;\n" +
   8296 "\n" +
   8297 "/* Allocate and link a region entry in the region list */\n" +
   8298 "static int region_list_append (region_list_entry **last, void *base_reserved, long reserve_size) {\n" +
   8299 "    region_list_entry *next = HeapAlloc (GetProcessHeap (), 0, sizeof (region_list_entry));\n" +
   8300 "    if (! next)\n" +
   8301 "        return FALSE;\n" +
   8302 "    next->top_allocated = (char *) base_reserved;\n" +
   8303 "    next->top_committed = (char *) base_reserved;\n" +
   8304 "    next->top_reserved = (char *) base_reserved + reserve_size;\n" +
   8305 "    next->reserve_size = reserve_size;\n" +
   8306 "    next->previous = *last;\n" +
   8307 "    *last = next;\n" +
   8308 "    return TRUE;\n" +
   8309 "}\n" +
   8310 "/* Free and unlink the last region entry from the region list */\n" +
   8311 "static int region_list_remove (region_list_entry **last) {\n" +
   8312 "    region_list_entry *previous = (*last)->previous;\n" +
   8313 "    if (! HeapFree (GetProcessHeap (), sizeof (region_list_entry), *last))\n" +
   8314 "        return FALSE;\n" +
   8315 "    *last = previous;\n" +
   8316 "    return TRUE;\n" +
   8317 "}\n" +
   8318 "\n" +
   8319 "#define CEIL(size,to)   (((size)+(to)-1)&~((to)-1))\n" +
   8320 "#define FLOOR(size,to)  ((size)&~((to)-1))\n" +
   8321 "\n" +
   8322 "#define SBRK_SCALE  0\n" +
   8323 "/* #define SBRK_SCALE  1 */\n" +
   8324 "/* #define SBRK_SCALE  2 */\n" +
   8325 "/* #define SBRK_SCALE  4  */\n" +
   8326 "\n" +
   8327 "/* sbrk for windows */\n" +
   8328 "static void *sbrk (long size) {\n" +
   8329 "    static long g_pagesize, g_my_pagesize;\n" +
   8330 "    static long g_regionsize, g_my_regionsize;\n" +
   8331 "    static region_list_entry *g_last;\n" +
   8332 "    void *result = (void *) MORECORE_FAILURE;\n" +
   8333 "#ifdef TRACE\n" +
   8334 "    printf (\"sbrk %d\\n\", size);\n" +
   8335 "#endif\n" +
   8336 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8337 "    /* Wait for spin lock */\n" +
   8338 "    slwait (&g_sl);\n" +
   8339 "#endif\n" +
   8340 "    /* First time initialization */\n" +
   8341 "    if (! g_pagesize) {\n" +
   8342 "        g_pagesize = getpagesize ();\n" +
   8343 "        g_my_pagesize = g_pagesize << SBRK_SCALE;\n" +
   8344 "    }\n" +
   8345 "    if (! g_regionsize) {\n" +
   8346 "        g_regionsize = getregionsize ();\n" +
   8347 "        g_my_regionsize = g_regionsize << SBRK_SCALE;\n" +
   8348 "    }\n" +
   8349 "    if (! g_last) {\n" +
   8350 "        if (! region_list_append (&g_last, 0, 0))\n" +
   8351 "           goto sbrk_exit;\n" +
   8352 "    }\n" +
   8353 "    /* Assert invariants */\n" +
   8354 "    assert (g_last);\n" +
   8355 "    assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_allocated &&\n" +
   8356 "            g_last->top_allocated <= g_last->top_committed);\n" +
   8357 "    assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_committed &&\n" +
   8358 "            g_last->top_committed <= g_last->top_reserved &&\n" +
   8359 "            (unsigned) g_last->top_committed % g_pagesize == 0);\n" +
   8360 "    assert ((unsigned) g_last->top_reserved % g_regionsize == 0);\n" +
   8361 "    assert ((unsigned) g_last->reserve_size % g_regionsize == 0);\n" +
   8362 "    /* Allocation requested? */\n" +
   8363 "    if (size >= 0) {\n" +
   8364 "        /* Allocation size is the requested size */\n" +
   8365 "        long allocate_size = size;\n" +
   8366 "        /* Compute the size to commit */\n" +
   8367 "        long to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed;\n" +
   8368 "        /* Do we reach the commit limit? */\n" +
   8369 "        if (to_commit > 0) {\n" +
   8370 "            /* Round size to commit */\n" +
   8371 "            long commit_size = CEIL (to_commit, g_my_pagesize);\n" +
   8372 "            /* Compute the size to reserve */\n" +
   8373 "            long to_reserve = (char *) g_last->top_committed + commit_size - (char *) g_last->top_reserved;\n" +
   8374 "            /* Do we reach the reserve limit? */\n" +
   8375 "            if (to_reserve > 0) {\n" +
   8376 "                /* Compute the remaining size to commit in the current region */\n" +
   8377 "                long remaining_commit_size = (char *) g_last->top_reserved - (char *) g_last->top_committed;\n" +
   8378 "                if (remaining_commit_size > 0) {\n" +
   8379 "                    /* Assert preconditions */\n" +
   8380 "                    assert ((unsigned) g_last->top_committed % g_pagesize == 0);\n" +
   8381 "                    assert (0 < remaining_commit_size && remaining_commit_size % g_pagesize == 0); {\n" +
   8382 "                        /* Commit this */\n" +
   8383 "                        void *base_committed = VirtualAlloc (g_last->top_committed, remaining_commit_size,\n" +
   8384 "                                                             MEM_COMMIT, PAGE_READWRITE);\n" +
   8385 "                        /* Check returned pointer for consistency */\n" +
   8386 "                        if (base_committed != g_last->top_committed)\n" +
   8387 "                            goto sbrk_exit;\n") +
   8388 (
   8389 "                        /* Assert postconditions */\n" +
   8390 "                        assert ((unsigned) base_committed % g_pagesize == 0);\n" +
   8391 "#ifdef TRACE\n" +
   8392 "                        printf (\"Commit %p %d\\n\", base_committed, remaining_commit_size);\n" +
   8393 "#endif\n" +
   8394 "                        /* Adjust the regions commit top */\n" +
   8395 "                        g_last->top_committed = (char *) base_committed + remaining_commit_size;\n" +
   8396 "                    }\n" +
   8397 "                } {\n" +
   8398 "                    /* Now we are going to search and reserve. */\n" +
   8399 "                    int contiguous = -1;\n" +
   8400 "                    int found = FALSE;\n" +
   8401 "                    MEMORY_BASIC_INFORMATION memory_info;\n" +
   8402 "                    void *base_reserved;\n" +
   8403 "                    long reserve_size;\n" +
   8404 "                    do {\n" +
   8405 "                        /* Assume contiguous memory */\n" +
   8406 "                        contiguous = TRUE;\n" +
   8407 "                        /* Round size to reserve */\n" +
   8408 "                        reserve_size = CEIL (to_reserve, g_my_regionsize);\n" +
   8409 "                        /* Start with the current region's top */\n" +
   8410 "                        memory_info.BaseAddress = g_last->top_reserved;\n" +
   8411 "                        /* Assert preconditions */\n" +
   8412 "                        assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0);\n" +
   8413 "                        assert (0 < reserve_size && reserve_size % g_regionsize == 0);\n" +
   8414 "                        while (VirtualQuery (memory_info.BaseAddress, &memory_info, sizeof (memory_info))) {\n" +
   8415 "                            /* Assert postconditions */\n" +
   8416 "                            assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0);\n" +
   8417 "#ifdef TRACE\n" +
   8418 "                            printf (\"Query %p %d %s\\n\", memory_info.BaseAddress, memory_info.RegionSize,\n" +
   8419 "                                    memory_info.State == MEM_FREE ? \"FREE\":\n" +
   8420 "                                    (memory_info.State == MEM_RESERVE ? \"RESERVED\":\n" +
   8421 "                                     (memory_info.State == MEM_COMMIT ? \"COMMITTED\": \"?\")));\n" +
   8422 "#endif\n" +
   8423 "                            /* Region is free, well aligned and big enough: we are done */\n" +
   8424 "                            if (memory_info.State == MEM_FREE &&\n" +
   8425 "                                (unsigned) memory_info.BaseAddress % g_regionsize == 0 &&\n" +
   8426 "                                memory_info.RegionSize >= (unsigned) reserve_size) {\n" +
   8427 "                                found = TRUE;\n" +
   8428 "                                break;\n" +
   8429 "                            }\n" +
   8430 "                            /* From now on we can't get contiguous memory! */\n" +
   8431 "                            contiguous = FALSE;\n" +
   8432 "                            /* Recompute size to reserve */\n" +
   8433 "                            reserve_size = CEIL (allocate_size, g_my_regionsize);\n" +
   8434 "                            memory_info.BaseAddress = (char *) memory_info.BaseAddress + memory_info.RegionSize;\n" +
   8435 "                            /* Assert preconditions */\n" +
   8436 "                            assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0);\n" +
   8437 "                            assert (0 < reserve_size && reserve_size % g_regionsize == 0);\n" +
   8438 "                        }\n" +
   8439 "                        /* Search failed? */\n" +
   8440 "                        if (! found)\n" +
   8441 "                            goto sbrk_exit;\n" +
   8442 "                        /* Assert preconditions */\n" +
   8443 "                        assert ((unsigned) memory_info.BaseAddress % g_regionsize == 0);\n" +
   8444 "                        assert (0 < reserve_size && reserve_size % g_regionsize == 0);\n" +
   8445 "                        /* Try to reserve this */\n" +
   8446 "                        base_reserved = VirtualAlloc (memory_info.BaseAddress, reserve_size,\n" +
   8447 "                                                      MEM_RESERVE, PAGE_NOACCESS);\n" +
   8448 "                        if (! base_reserved) {\n" +
   8449 "                            int rc = GetLastError ();\n" +
   8450 "                            if (rc != ERROR_INVALID_ADDRESS)\n" +
   8451 "                                goto sbrk_exit;\n" +
   8452 "                        }\n" +
   8453 "                        /* A null pointer signals (hopefully) a race condition with another thread. */\n" +
   8454 "                        /* In this case, we try again. */\n" +
   8455 "                    } while (! base_reserved);\n" +
   8456 "                    /* Check returned pointer for consistency */\n" +
   8457 "                    if (memory_info.BaseAddress && base_reserved != memory_info.BaseAddress)\n" +
   8458 "                        goto sbrk_exit;\n" +
   8459 "                    /* Assert postconditions */\n" +
   8460 "                    assert ((unsigned) base_reserved % g_regionsize == 0);\n" +
   8461 "#ifdef TRACE\n" +
   8462 "                    printf (\"Reserve %p %d\\n\", base_reserved, reserve_size);\n" +
   8463 "#endif\n" +
   8464 "                    /* Did we get contiguous memory? */\n" +
   8465 "                    if (contiguous) {\n" +
   8466 "                        long start_size = (char *) g_last->top_committed - (char *) g_last->top_allocated;\n" +
   8467 "                        /* Adjust allocation size */\n" +
   8468 "                        allocate_size -= start_size;\n" +
   8469 "                        /* Adjust the regions allocation top */\n" +
   8470 "                        g_last->top_allocated = g_last->top_committed;\n" +
   8471 "                        /* Recompute the size to commit */\n" +
   8472 "                        to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed;\n" +
   8473 "                        /* Round size to commit */\n" +
   8474 "                        commit_size = CEIL (to_commit, g_my_pagesize);\n" +
   8475 "                    }\n" +
   8476 "                    /* Append the new region to the list */\n" +
   8477 "                    if (! region_list_append (&g_last, base_reserved, reserve_size))\n" +
   8478 "                        goto sbrk_exit;\n" +
   8479 "                    /* Didn't we get contiguous memory? */\n" +
   8480 "                    if (! contiguous) {\n" +
   8481 "                        /* Recompute the size to commit */\n" +
   8482 "                        to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed;\n" +
   8483 "                        /* Round size to commit */\n" +
   8484 "                        commit_size = CEIL (to_commit, g_my_pagesize);\n" +
   8485 "                    }\n" +
   8486 "                }\n" +
   8487 "            }\n" +
   8488 "            /* Assert preconditions */\n" +
   8489 "            assert ((unsigned) g_last->top_committed % g_pagesize == 0);\n" +
   8490 "            assert (0 < commit_size && commit_size % g_pagesize == 0); {\n" +
   8491 "                /* Commit this */\n" +
   8492 "                void *base_committed = VirtualAlloc (g_last->top_committed, commit_size,\n" +
   8493 "                                                     MEM_COMMIT, PAGE_READWRITE);\n" +
   8494 "                /* Check returned pointer for consistency */\n" +
   8495 "                if (base_committed != g_last->top_committed)\n" +
   8496 "                    goto sbrk_exit;\n" +
   8497 "                /* Assert postconditions */\n" +
   8498 "                assert ((unsigned) base_committed % g_pagesize == 0);\n" +
   8499 "#ifdef TRACE\n" +
   8500 "                printf (\"Commit %p %d\\n\", base_committed, commit_size);\n" +
   8501 "#endif\n" +
   8502 "                /* Adjust the regions commit top */\n" +
   8503 "                g_last->top_committed = (char *) base_committed + commit_size;\n" +
   8504 "            }\n" +
   8505 "        }\n" +
   8506 "        /* Adjust the regions allocation top */\n" +
   8507 "        g_last->top_allocated = (char *) g_last->top_allocated + allocate_size;\n" +
   8508 "        result = (char *) g_last->top_allocated - size;\n" +
   8509 "    /* Deallocation requested? */\n" +
   8510 "    } else if (size < 0) {\n" +
   8511 "        long deallocate_size = - size;\n" +
   8512 "        /* As long as we have a region to release */\n" +
   8513 "        while ((char *) g_last->top_allocated - deallocate_size < (char *) g_last->top_reserved - g_last->reserve_size) {\n" +
   8514 "            /* Get the size to release */\n" +
   8515 "            long release_size = g_last->reserve_size;\n" +
   8516 "            /* Get the base address */\n" +
   8517 "            void *base_reserved = (char *) g_last->top_reserved - release_size;\n" +
   8518 "            /* Assert preconditions */\n" +
   8519 "            assert ((unsigned) base_reserved % g_regionsize == 0);\n" +
   8520 "            assert (0 < release_size && release_size % g_regionsize == 0); {\n" +
   8521 "                /* Release this */\n" +
   8522 "                int rc = VirtualFree (base_reserved, 0,\n" +
   8523 "                                      MEM_RELEASE);\n" +
   8524 "                /* Check returned code for consistency */\n" +
   8525 "                if (! rc)\n" +
   8526 "                    goto sbrk_exit;\n" +
   8527 "#ifdef TRACE\n" +
   8528 "                printf (\"Release %p %d\\n\", base_reserved, release_size);\n" +
   8529 "#endif\n" +
   8530 "            }\n" +
   8531 "            /* Adjust deallocation size */\n" +
   8532 "            deallocate_size -= (char *) g_last->top_allocated - (char *) base_reserved;\n" +
   8533 "            /* Remove the old region from the list */\n" +
   8534 "            if (! region_list_remove (&g_last))\n" +
   8535 "                goto sbrk_exit;\n" +
   8536 "        } {\n") +
   8537 (
   8538 "            /* Compute the size to decommit */\n" +
   8539 "            long to_decommit = (char *) g_last->top_committed - ((char *) g_last->top_allocated - deallocate_size);\n" +
   8540 "            if (to_decommit >= g_my_pagesize) {\n" +
   8541 "                /* Compute the size to decommit */\n" +
   8542 "                long decommit_size = FLOOR (to_decommit, g_my_pagesize);\n" +
   8543 "                /*  Compute the base address */\n" +
   8544 "                void *base_committed = (char *) g_last->top_committed - decommit_size;\n" +
   8545 "                /* Assert preconditions */\n" +
   8546 "                assert ((unsigned) base_committed % g_pagesize == 0);\n" +
   8547 "                assert (0 < decommit_size && decommit_size % g_pagesize == 0); {\n" +
   8548 "                    /* Decommit this */\n" +
   8549 "                    int rc = VirtualFree ((char *) base_committed, decommit_size,\n" +
   8550 "                                          MEM_DECOMMIT);\n" +
   8551 "                    /* Check returned code for consistency */\n" +
   8552 "                    if (! rc)\n" +
   8553 "                        goto sbrk_exit;\n" +
   8554 "#ifdef TRACE\n" +
   8555 "                    printf (\"Decommit %p %d\\n\", base_committed, decommit_size);\n" +
   8556 "#endif\n" +
   8557 "                }\n" +
   8558 "                /* Adjust deallocation size and regions commit and allocate top */\n" +
   8559 "                deallocate_size -= (char *) g_last->top_allocated - (char *) base_committed;\n" +
   8560 "                g_last->top_committed = base_committed;\n" +
   8561 "                g_last->top_allocated = base_committed;\n" +
   8562 "            }\n" +
   8563 "        }\n" +
   8564 "        /* Adjust regions allocate top */\n" +
   8565 "        g_last->top_allocated = (char *) g_last->top_allocated - deallocate_size;\n" +
   8566 "        /* Check for underflow */\n" +
   8567 "        if ((char *) g_last->top_reserved - g_last->reserve_size > (char *) g_last->top_allocated ||\n" +
   8568 "            g_last->top_allocated > g_last->top_committed) {\n" +
   8569 "            /* Adjust regions allocate top */\n" +
   8570 "            g_last->top_allocated = (char *) g_last->top_reserved - g_last->reserve_size;\n" +
   8571 "            goto sbrk_exit;\n" +
   8572 "        }\n" +
   8573 "        result = g_last->top_allocated;\n" +
   8574 "    }\n" +
   8575 "    /* Assert invariants */\n" +
   8576 "    assert (g_last);\n" +
   8577 "    assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_allocated &&\n" +
   8578 "            g_last->top_allocated <= g_last->top_committed);\n" +
   8579 "    assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_committed &&\n" +
   8580 "            g_last->top_committed <= g_last->top_reserved &&\n" +
   8581 "            (unsigned) g_last->top_committed % g_pagesize == 0);\n" +
   8582 "    assert ((unsigned) g_last->top_reserved % g_regionsize == 0);\n" +
   8583 "    assert ((unsigned) g_last->reserve_size % g_regionsize == 0);\n" +
   8584 "\n" +
   8585 "sbrk_exit:\n" +
   8586 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8587 "    /* Release spin lock */\n" +
   8588 "    slrelease (&g_sl);\n" +
   8589 "#endif\n" +
   8590 "    return result;\n" +
   8591 "}\n" +
   8592 "\n" +
   8593 "/* mmap for windows */\n" +
   8594 "static void *mmap (void *ptr, long size, long prot, long type, long handle, long arg) {\n" +
   8595 "    static long g_pagesize;\n" +
   8596 "    static long g_regionsize;\n" +
   8597 "#ifdef TRACE\n" +
   8598 "    printf (\"mmap %d\\n\", size);\n" +
   8599 "#endif\n" +
   8600 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8601 "    /* Wait for spin lock */\n" +
   8602 "    slwait (&g_sl);\n" +
   8603 "#endif\n" +
   8604 "    /* First time initialization */\n" +
   8605 "    if (! g_pagesize)\n" +
   8606 "        g_pagesize = getpagesize ();\n" +
   8607 "    if (! g_regionsize)\n" +
   8608 "        g_regionsize = getregionsize ();\n" +
   8609 "    /* Assert preconditions */\n" +
   8610 "    assert ((unsigned) ptr % g_regionsize == 0);\n" +
   8611 "    assert (size % g_pagesize == 0);\n" +
   8612 "    /* Allocate this */\n" +
   8613 "    ptr = VirtualAlloc (ptr, size,\n" +
   8614 "                        MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE);\n" +
   8615 "    if (! ptr) {\n" +
   8616 "        ptr = (void *) MORECORE_FAILURE;\n" +
   8617 "        goto mmap_exit;\n" +
   8618 "    }\n" +
   8619 "    /* Assert postconditions */\n" +
   8620 "    assert ((unsigned) ptr % g_regionsize == 0);\n" +
   8621 "#ifdef TRACE\n" +
   8622 "    printf (\"Commit %p %d\\n\", ptr, size);\n" +
   8623 "#endif\n" +
   8624 "mmap_exit:\n" +
   8625 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8626 "    /* Release spin lock */\n" +
   8627 "    slrelease (&g_sl);\n" +
   8628 "#endif\n" +
   8629 "    return ptr;\n" +
   8630 "}\n" +
   8631 "\n" +
   8632 "/* munmap for windows */\n" +
   8633 "static long munmap (void *ptr, long size) {\n" +
   8634 "    static long g_pagesize;\n" +
   8635 "    static long g_regionsize;\n" +
   8636 "    int rc = MUNMAP_FAILURE;\n" +
   8637 "#ifdef TRACE\n" +
   8638 "    printf (\"munmap %p %d\\n\", ptr, size);\n" +
   8639 "#endif\n" +
   8640 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8641 "    /* Wait for spin lock */\n" +
   8642 "    slwait (&g_sl);\n" +
   8643 "#endif\n" +
   8644 "    /* First time initialization */\n" +
   8645 "    if (! g_pagesize)\n" +
   8646 "        g_pagesize = getpagesize ();\n" +
   8647 "    if (! g_regionsize)\n" +
   8648 "        g_regionsize = getregionsize ();\n" +
   8649 "    /* Assert preconditions */\n" +
   8650 "    assert ((unsigned) ptr % g_regionsize == 0);\n" +
   8651 "    assert (size % g_pagesize == 0);\n" +
   8652 "    /* Free this */\n" +
   8653 "    if (! VirtualFree (ptr, 0,\n" +
   8654 "                       MEM_RELEASE))\n" +
   8655 "        goto munmap_exit;\n" +
   8656 "    rc = 0;\n" +
   8657 "#ifdef TRACE\n" +
   8658 "    printf (\"Release %p %d\\n\", ptr, size);\n" +
   8659 "#endif\n" +
   8660 "munmap_exit:\n" +
   8661 "#if defined (USE_MALLOC_LOCK) && defined (NEEDED)\n" +
   8662 "    /* Release spin lock */\n" +
   8663 "    slrelease (&g_sl);\n" +
   8664 "#endif\n" +
   8665 "    return rc;\n" +
   8666 "}\n" +
   8667 "\n" +
   8668 "static void vminfo (CHUNK_SIZE_T  *free, CHUNK_SIZE_T  *reserved, CHUNK_SIZE_T  *committed) {\n" +
   8669 "    MEMORY_BASIC_INFORMATION memory_info;\n" +
   8670 "    memory_info.BaseAddress = 0;\n" +
   8671 "    *free = *reserved = *committed = 0;\n" +
   8672 "    while (VirtualQuery (memory_info.BaseAddress, &memory_info, sizeof (memory_info))) {\n" +
   8673 "        switch (memory_info.State) {\n" +
   8674 "        case MEM_FREE:\n" +
   8675 "            *free += memory_info.RegionSize;\n" +
   8676 "            break;\n" +
   8677 "        case MEM_RESERVE:\n" +
   8678 "            *reserved += memory_info.RegionSize;\n" +
   8679 "            break;\n" +
   8680 "        case MEM_COMMIT:\n" +
   8681 "            *committed += memory_info.RegionSize;\n" +
   8682 "            break;\n" +
   8683 "        }\n" +
   8684 "        memory_info.BaseAddress = (char *) memory_info.BaseAddress + memory_info.RegionSize;\n" +
   8685 "    }\n" +
   8686 "}\n" +
   8687 "\n") +
   8688 (
   8689 "static int cpuinfo (int whole, CHUNK_SIZE_T  *kernel, CHUNK_SIZE_T  *user) {\n" +
   8690 "    if (whole) {\n" +
   8691 "        __int64 creation64, exit64, kernel64, user64;\n" +
   8692 "        int rc = GetProcessTimes (GetCurrentProcess (),\n" +
   8693 "                                  (FILETIME *) &creation64,\n" +
   8694 "                                  (FILETIME *) &exit64,\n" +
   8695 "                                  (FILETIME *) &kernel64,\n" +
   8696 "                                  (FILETIME *) &user64);\n" +
   8697 "        if (! rc) {\n" +
   8698 "            *kernel = 0;\n" +
   8699 "            *user = 0;\n" +
   8700 "            return FALSE;\n" +
   8701 "        }\n" +
   8702 "        *kernel = (CHUNK_SIZE_T) (kernel64 / 10000);\n" +
   8703 "        *user = (CHUNK_SIZE_T) (user64 / 10000);\n" +
   8704 "        return TRUE;\n" +
   8705 "    } else {\n" +
   8706 "        __int64 creation64, exit64, kernel64, user64;\n" +
   8707 "        int rc = GetThreadTimes (GetCurrentThread (),\n" +
   8708 "                                 (FILETIME *) &creation64,\n" +
   8709 "                                 (FILETIME *) &exit64,\n" +
   8710 "                                 (FILETIME *) &kernel64,\n" +
   8711 "                                 (FILETIME *) &user64);\n" +
   8712 "        if (! rc) {\n" +
   8713 "            *kernel = 0;\n" +
   8714 "            *user = 0;\n" +
   8715 "            return FALSE;\n" +
   8716 "        }\n" +
   8717 "        *kernel = (CHUNK_SIZE_T) (kernel64 / 10000);\n" +
   8718 "        *user = (CHUNK_SIZE_T) (user64 / 10000);\n" +
   8719 "        return TRUE;\n" +
   8720 "    }\n" +
   8721 "}\n" +
   8722 "\n" +
   8723 "#endif /* WIN32 */\n" +
   8724 "\n" +
   8725 "#endif // NDEBUG\n" +
   8726 "\n" +
   8727 "};  /* end of namespace KJS */\n");
   8728 
   8729 
   8730 var thai =
   8731 "\n" +
   8732 " \n" +
   8733 ": , \n" +
   8734 "	\n" +
   8735 "\n" +
   8736 "   \n" +
   8737 "   \n" +
   8738 "   \n" +
   8739 ":\n" +
   8740 "\n" +
   8741 "    \"\"     ()\n" +
   8742 "\n" +
   8743 "\n" +
   8744 " 	\n" +
   8745 " 	\n" +
   8746 ":   \n" +
   8747 ": \n" +
   8748 "\n" +
   8749 " 	\n" +
   8750 "1344N 10030E\n" +
   8751 " 	\n" +
   8752 " 	\n" +
   8753 " 	\n" +
   8754 " -  	\n" +
   8755 " -  	 \n" +
   8756 " -  	   ()\n" +
   8757 "\n" +
   8758 " \n" +
   8759 " \n" +
   8760 " \n" +
   8761 "  	\n" +
   8762 ".. 17811911\n" +
   8763 "18932310\n" +
   8764 "23106  2325\n" +
   8765 "6  2325\n" +
   8766 "\n" +
   8767 " - \n" +
   8768 " \n" +
   8769 " -  (%) 	 \n" +
   8770 "514,000 . ( 49)\n" +
   8771 "198,457  \n" +
   8772 "0.4%\n" +
   8773 "\n" +
   8774 " - 2548 \n" +
   8775 " - 2543\n" +
   8776 " -  	 \n" +
   8777 "62,418,054 ( 19)\n" +
   8778 "60,916,441\n" +
   8779 "122/ ( 59)\n" +
   8780 "{{{population_densitymi}}}/ \n" +
   8781 "GDP (PPP)\n" +
   8782 " - \n" +
   8783 " -  	2548 \n" +
   8784 "$559.5 billion ( 21)\n" +
   8785 "$8,542 ( 72)\n" +
   8786 "HDI (2546) 	0.778 ( 73)  \n" +
   8787 " 	 () (THB)\n" +
   8788 " 	(UTC+7)\n" +
   8789 " 	.th\n" +
   8790 " 	+66\n" +
   8791 "\n" +
   8792 "        \n" +
   8793 "\n" +
   8794 "      \n" +
   8795 "\n" +
   8796 "    60 \n" +
   8797 "\n" +
   8798 "\n" +
   8799 "\n" +
   8800 "[]\n" +
   8801 "\n" +
   8802 "    * 1 \n" +
   8803 "          o 1.1 \n" +
   8804 "    * 2 \n" +
   8805 "          o 2.1 \n" +
   8806 "          o 2.2  / \n" +
   8807 "    * 3 \n" +
   8808 "          o 3.1 \n" +
   8809 "          o 3.2 \n" +
   8810 "    * 4 \n" +
   8811 "          o 4.1 \n" +
   8812 "          o 4.2 \n" +
   8813 "          o 4.3 \n" +
   8814 "    * 5 \n" +
   8815 "          o 5.1 \n" +
   8816 "          o 5.2 \n" +
   8817 "          o 5.3 \n" +
   8818 "          o 5.4 \n" +
   8819 "          o 5.5 \n" +
   8820 "          o 5.6 \n" +
   8821 "          o 5.7 \n" +
   8822 "    * 6 \n" +
   8823 "    * 7 \n" +
   8824 "    * 8 \n" +
   8825 "\n" +
   8826 "\n" +
   8827 "\n" +
   8828 "     \n" +
   8829 "\n" +
   8830 "-    13 [1]        .. 1781   19      .. 2310 \n" +
   8831 "\n" +
   8832 " .. 2325    5   ()   24  .. 2475  41   .. 2516  14    6     .. 2549   2549\n" +
   8833 "\n" +
   8834 "\n" +
   8835 "\n" +
   8836 "             (Siam)   .. 2482   1  .      \"\"  .. 2488   .. 2491  .   [2] \"Siam\"  .. 2491  \"Thalande\"  \"Thailand\"     .\n" +
   8837 "\n" +
   8838 "\n" +
   8839 "\n" +
   8840 "  24  .. 2475              \n" +
   8841 "\n" +
   8842 "    19  .. 2549\n" +
   8843 "\n" +
   8844 "\n" +
   8845 "\n" +
   8846 "   75         '' .. 2542\n" +
   8847 "\n" +
   8848 "     \n" +
   8849 "\n" +
   8850 " / \n" +
   8851 " \n" +
   8852 " \n" +
   8853 "\n" +
   8854 "\n" +
   8855 "\n" +
   8856 "  ( .. 2549    )   \n" +
   8857 " 	 /  	 	\n" +
   8858 "1 	 	6,121,672 	\n" +
   8859 "2 	 	266,941 	\n" +
   8860 "3 	 	167,138 	\n" +
   8861 "4 	 	157,678 	\n" +
   8862 "5 	 	150,805 	\n" +
   8863 "6 	 	149,938 	\n" +
   8864 "7 	 	142,670 	\n" +
   8865 "8 	 	124,665 	\n" +
   8866 "9 	 	121,283 	\n" +
   8867 "10 	 	106,293 	\n" +
   8868 "\n" +
   8869 "\n" +
   8870 " 	 	 	\n" +
   8871 "1 	 	6,121,672 	\n" +
   8872 "2 	 	2,546,763 	\n" +
   8873 "3 	 	1,774,808 	\n" +
   8874 "4 	 	1,747,542 	\n" +
   8875 "5 	 	1,650,009 	\n" +
   8876 "6 	 	1,531,430 	\n" +
   8877 "7 	 	1,523,802 	\n" +
   8878 "8 	 	1,504,420 	\n" +
   8879 "9 	 	1,443,975 	\n" +
   8880 "10 	 	1,374,700 	\n" +
   8881 "\n" +
   8882 "       \n" +
   8883 "\n" +
   8884 "\n" +
   8885 "\n" +
   8886 "\n" +
   8887 " \n" +
   8888 " \n" +
   8889 "\n" +
   8890 "     (2,576 )       \n" +
   8891 "\n" +
   8892 "    *    \n" +
   8893 "          o   1.3 \n" +
   8894 "          o   3.7 \n" +
   8895 "          o   6.4 \n" +
   8896 "          o     19 \n" +
   8897 "          o   33 \n" +
   8898 "          o     \n" +
   8899 "\n" +
   8900 " 26  .. 2547 \n" +
   8901 "\n" +
   8902 "\n" +
   8903 "\n" +
   8904 " - -    \n" +
   8905 "\n" +
   8906 "\n" +
   8907 "\n" +
   8908 "\n" +
   8909 "\n" +
   8910 "        .. 2546  GDP 5,930.4   78.1   74.3 [3]\n" +
   8911 "\n" +
   8912 "\n" +
   8913 "\n" +
   8914 "\n" +
   8915 "\n" +
   8916 "       36    20   18  14   12  [4]                2549  177,717.29   45,434.57  [5]\n" +
   8917 "\n" +
   8918 "          .. 2547  211.4   196.4   36.5   11.1   2.99      6.28   2.28   694   789  ]] 31.1  [6]\n" +
   8919 " \n" +
   8920 " \n" +
   8921 "\n" +
   8922 "   .. 2547  11.65  56.52%  ( 11.97%  10.33%)  24.29%  7.02% [7]     \n" +
   8923 "\n" +
   8924 "\n" +
   8925 "\n" +
   8926 " \n" +
   8927 "\n" +
   8928 "        ( 1)  ( 2)  ( 3)  ( 4)  ()  2  - ( 7)  ( -  9)                  \n" +
   8929 " \n" +
   8930 " \n" +
   8931 "\n" +
   8932 "     132.2   45   29  .. 2549  ()  92 \n" +
   8933 "\n" +
   8934 "   () \n" +
   8935 "\n" +
   8936 "\n" +
   8937 "\n" +
   8938 "    *  7.035  (2548)  27.4  (2548) [8]\n" +
   8939 "    * :  334  ,  204    6  (2542)  13.96  (2540) [8]\n" +
   8940 "    *   6  ()  111   15.19  (2540) [8]\n" +
   8941 "    *  th\n" +
   8942 "\n" +
   8943 "\n" +
   8944 " \n" +
   8945 " \n" +
   8946 "\n" +
   8947 "\n" +
   8948 "\n" +
   8949 "          () ()                    \n" +
   8950 "\n" +
   8951 " 75%  14%  11% [8]\n" +
   8952 "\n" +
   8953 "     \n" +
   8954 "\n" +
   8955 "\n" +
   8956 "  \n" +
   8957 "  \n" +
   8958 "\n" +
   8959 " 95 ()   4 ()  1\n" +
   8960 "\n" +
   8961 "     \n" +
   8962 "\n" +
   8963 "\n" +
   8964 "\n" +
   8965 "            \n" +
   8966 "\n" +
   8967 "  2         \n" +
   8968 "\n" +
   8969 "     \n" +
   8970 "\n" +
   8971 "\n" +
   8972 "\n" +
   8973 "     \n" +
   8974 "\n" +
   8975 "    4,000        \n" +
   8976 "\n" +
   8977 "\n" +
   8978 "  \n" +
   8979 "  \n" +
   8980 "\n" +
   8981 "   \n" +
   8982 "\n" +
   8983 "    *           \n" +
   8984 "    *                 \n" +
   8985 "    *          \n" +
   8986 "\n" +
   8987 "     \n" +
   8988 "\n" +
   8989 "\n" +
   8990 " \n" +
   8991 " \n" +
   8992 "\n" +
   8993 "     3   1972             \n" +
   8994 "\n" +
   8995 " 4    5  \n" +
   8996 "\n" +
   8997 " \n" +
   8998 "\n" +
   8999 "    *  -  ,  ,  ,  \n" +
   9000 "    *  -  ,  ,  \n" +
   9001 "    *  -  (),  ,  \n" +
   9002 "    *  -  ,  \n" +
   9003 "    *  -  \n" +
   9004 "    *  -  \n" +
   9005 "    *  -  \n" +
   9006 "    *  -  ,  \n" +
   9007 "    *  -  \n" +
   9008 "\n" +
   9009 "\n" +
   9010 "\n" +
   9011 "   5     \n" +
   9012 "\n" +
   9013 "     \n" +
   9014 "\n" +
   9015 "\n" +
   9016 "\n" +
   9017 "    *  \n" +
   9018 "    *   (169 )\n" +
   9019 "    *   71  155   Index of Economic Freedom\n" +
   9020 "    *  Modern Maturity  .. 2544  7  [9]\n" +
   9021 "    * Growth Competitiveness Index Ranking .. 2546  34  104 [10]\n" +
   9022 "    *  2   30  .. 2549\n" +
   9023 "\n" +
   9024 "\n" +
   9025 "\n" +
   9026 "   1.  4th edition \"ANKOR an introduction to the temples\" Dawn Rooney ISBN: 962-217-683-6\n" +
   9027 "   2.   ( 17 )  (lingua franca)     \n" +
   9028 "   3.   \n" +
   9029 "   4.         01  .. 2550  19  408\n" +
   9030 "   5.  http://www.thairath.co.th/news.php?section=agriculture&content=52868\n" +
   9031 "   6.   \n" +
   9032 "   7.    ()\n" +
   9033 "   8.  8.0 8.1 8.2 8.3 \n" +
   9034 "   9.  http://207.5.46.81/tat_news/detail.asp?id=963\n" +
   9035 "  10.   Webforum.org .. 2546\n" +
   9036 "\n" +
   9037 "\n" +
   9038 "Commons\n" +
   9039 "  :\n" +
   9040 "\n" +
   9041 "\n" +
   9042 " : \n" +
   9043 "\n" +
   9044 "    * \n" +
   9045 "    * \n" +
   9046 "    *   \n" +
   9047 "    * \n" +
   9048 "    *  Longdo Map\n";
   9049 
   9050 function get_most_popular(text) {
   9051   var i;
   9052   var frequencies = new Object();
   9053   var letter;
   9054   for (i = 0; i < text.length; i++) {
   9055     letter = text.charAt(i);
   9056     if (typeof(frequencies[letter]) == 'undefined')
   9057       frequencies[letter] = 0;
   9058     frequencies[letter]++;
   9059   }
   9060   var most = [];
   9061   for (letter in frequencies) {
   9062     if (frequencies[letter] > 50) {
   9063       most.push(letter);
   9064     }
   9065   }
   9066   most.sort();
   9067   return most;
   9068 }
   9069 
   9070 
   9071 var languages = new Array(
   9072     chinese,     // 1
   9073     cyrillic,    // 2
   9074     devanagari,  // 3
   9075     english,     // 4
   9076     greek,       // 5
   9077     hebrew,      // 6
   9078     japanese,    // 7
   9079     korean,      // 8
   9080     persian,     // 9
   9081     source,      // 10
   9082     thai);       // 11
   9083 
   9084 
   9085 var number_re = /[0-9]/;
   9086 var latin_lc = "[a-zA\u0631]";
   9087 assertEquals(7, latin_lc.length);
   9088 var latin_lc_re = new RegExp(latin_lc);
   9089 var latin_lc_re2 = new RegExp(/[a-zA\u0631]/);
   9090 
   9091 assertEquals(13793, chinese.length, "chinese utf8 in source");
   9092 assertEquals(60606, cyrillic.length, "cyrillic utf8 in source");
   9093 assertEquals(20203, devanagari.length, "devanagari utf8 in source");
   9094 assertEquals(37505, english.length, "english utf8 in source");
   9095 assertEquals(30052, greek.length, "greek utf8 in source");
   9096 assertEquals(25640, hebrew.length, "hebrew utf8 in source");
   9097 assertEquals(31082, japanese.length, "japanese utf8 in source");
   9098 assertEquals(12291, korean.length, "korean utf8 in source");
   9099 assertEquals(13851, persian.length, "persian utf8 in source");
   9100 assertEquals(177470, source.length, "source utf8 in source");
   9101 assertEquals(18315, thai.length, "thai utf8 in source");
   9102 
   9103 munged_sizes = new Array(17197, 2511, 2645, 3820, 3086, 2609,
   9104                          27231, 12972, 2014, 24943, 2773);
   9105 
   9106 
   9107 var i = 0;
   9108 for (idx in languages) {
   9109   i++;
   9110   var text = languages[idx];
   9111   assertTrue(latin_lc_re.test(text), "latin_lc" + i);
   9112   assertTrue(latin_lc_re2.test(text), "latin_lc" + i);
   9113   assertTrue(number_re.test(text), "number " + i);
   9114   var most_popular = get_most_popular(text);
   9115   var idx;
   9116   var re = "([x";
   9117   var last_c = -9999;
   9118   for (idx in most_popular) {
   9119     var c = most_popular[idx];
   9120     if ("^]-\n\\".indexOf(c) == -1) {
   9121       if (c.charCodeAt(0) > last_c &&
   9122           c.charCodeAt(0) - 20 < last_c) {
   9123         re += "-" + c;
   9124         last_c = -9999;
   9125       } else {
   9126         re += c;
   9127         last_c = c.charCodeAt(0);
   9128       }
   9129     }
   9130   }
   9131   re += "]+)";
   9132   var char_class = new RegExp(re, "g");
   9133   var munged = text.replace(char_class, "foo");
   9134   assertEquals(munged_sizes[i - 1], munged.length, "munged size " + i);
   9135 }
   9136 
   9137 
   9138 function hex(x) {
   9139   x &= 15;
   9140   if (x < 10) {
   9141     return String.fromCharCode(x + 48);
   9142   } else {
   9143     return String.fromCharCode(x + 97 - 10);
   9144   }
   9145 }
   9146 
   9147 
   9148 function dump_re(re) {
   9149   var out = "";
   9150   for (var i = 0; i < re.length; i++) {
   9151     var c = re.charCodeAt(i);
   9152     if (c >= 32 && c <= 126) {
   9153       out += re[i];
   9154     } else if (c < 256) {
   9155       out += "\\x" + hex(c >> 4) + hex(c);
   9156     } else {
   9157       out += "\\u" + hex(c >> 12) + hex(c >> 8) + hex(c >> 4) + hex(c);
   9158     }
   9159   }
   9160   print ("re = " + out);
   9161 }
   9162 
   9163 var thai_l_thingy = "\u0e44";
   9164 var thai_l_regexp = new RegExp(thai_l_thingy);
   9165 var thai_l_regexp2 = new RegExp("[" + thai_l_thingy + "]");
   9166 assertTrue(thai_l_regexp.test(thai_l_thingy));
   9167 assertTrue(thai_l_regexp2.test(thai_l_thingy));
   9168 
   9169 
   9170