📄 malloc.3
字号:
%!PS-Adobe-1.0%%Creator: devps (Pipeline Associates, Inc.)%%CreationDate: Fri Sep 13 13:06:50 1996%%Pages: (atend)%%DocumentFonts: (atend)/devps 180 dict def devps begin/res 10.000000 def/y_offset 843 def/X{exch}bind def/mm {transform round X round X itransform} bind def/r{rmoveto}bind def/m{moveto}bind def/l{lineto}bind def/rl{rlineto}bind def/st{stroke}bind def/gs{gsave}bind def/gr{grestore}bind def/cp{currentpoint}bind def/np{newpath}bind def/ct{curveto}bind defsystemdict /setpacking known { /savepacking currentpacking def true setpacking } if/m0{0 0 moveto}bind def/xc{//res div}bind def/yc{//res neg div //y_offset add}bind def/lc{yc X xc X l st}bind def/mc{yc X xc X m}bind def/el{gs /a X def a div 1 X scale cp np a xc 2 div 0 360 arc st gr}bind def/ar{cp 7 2 roll np xc 5 1 roll atan 3 1 roll atan X arc st}bind def/sp{yc X xc X 6 2 roll yc X xc X 6 2 roll yc X xc X 6 2 roll ct}bind def/V{//res neg div //y_offset addcurrentpoint pop Xm}bind def/H{//res div0 transform X round X itransform popcurrentpoint X popmoveto}bind def/h{//res div 0 r}bind def/v{//res neg div 0 X r}bind def/S{X H show}bind def/A{H //res div 1 index stringwidth pop sub 1 index length div 0 3 2 roll ashow}bind def/psize 10 def/height 0 def/cheight { height 0 ne { height } { psize } ifelse } bind def/slant 0 def/FF{findfont X dup 30 div 0 mm pop setlinewidth /psize X def [psize 0 cheight slant sin slant cos div mul cheight 0 0] makefont setfont}bind def/shade{gs /dy X def /dx X def np m 0 /dy rl /dx 0 rl 0 /dy neg rl /dx neg 0 rl closepath .9 setgray fillgr}bind def1 setlinecap/resolution res 72 mul def/startFig { /SavedState save def userdict maxlength dict begin currentpoint transform DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap setlinewidth setmatrix itransform moveto /ury exch def /urx exch def /lly exch def /llx exch def /y exch 72 mul resolution div def /x exch 72 mul resolution div def currentpoint /cy exch def /cx exch def /sx x urx llx sub div def /sy y ury lly sub div def sx sy scale cx sx div llx sub cy sy div ury sub translate /DefFigCTM matrix currentmatrix def /initmatrix { DefFigCTM setmatrix } def /defaultmatrix { DefFigCTM exch copy } def /initgraphics { DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap setlinewidth setmatrix DefFigCTM setmatrix } def /showpage { initgraphics } def}bind def/clipFig { currentpoint 6 2 roll newpath 4 copy 4 2 roll moveto 6 -1 roll exch lineto exch lineto exch lineto closepath clip newpath moveto}bind def/doclip { llx lly urx ury clipFig } def/endFig { end SavedState restore}bind def/globalstart { fontnum psize slant height resolution currentpoint pagesave restore gsave }bind def/globalend { grestore moveto /resolution exch def /height exch def /slant exch def /psize exch def /fontnum exch def F /pagesave save def}bind def/fontnum 1 def systemdict /setpacking known { savepacking setpacking} ifend/BP{save mark devps begin m0/DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecapcurrentlinejoin currentdash currentgray currentmiterlimit ] cvx def}bind def/EP{end cleartomark restore showpage}def/Encoding-1 256 array def0 1 255 {Encoding-1 exch /.notdef put} forEncoding-1 8#301 StandardEncoding 8#101 26 getinterval putinterval %A-BEncoding-1 8#341 StandardEncoding 8#141 26 getinterval putinterval %a-bEncoding-1 8#241 StandardEncoding 8#301 16 getinterval putinterval %accentsEncoding-1 8#373 StandardEncoding 8#365 1 getinterval putinterval %dotlessiEncoding-1dup 8#41 /copyright putdup 8#42 /registered putdup 8#43 /trademark putdup 8#44 /logicalnot putdup 8#45 /Eth putdup 8#46 /eth putdup 8#47 /Thorn putdup 8#50 /thorn putdup 8#51 /brokenbar putdup 8#52 /degree putdup 8#53 /divide putdup 8#54 /multiply putdup 8#55 /minus putdup 8#56 /onehalf putdup 8#57 /onequarter putdup 8#60 /threequarters putdup 8#101 /Aacute putdup 8#102 /Acircumflex putdup 8#103 /Adieresis putdup 8#104 /Agrave putdup 8#105 /Aring putdup 8#106 /Atilde putdup 8#107 /Ccedilla putdup 8#110 /Eacute putdup 8#111 /Ecircumflex putdup 8#112 /Edieresis putdup 8#113 /Egrave putdup 8#114 /Iacute putdup 8#115 /Icircumflex putdup 8#116 /Idieresis putdup 8#117 /Igrave putdup 8#120 /Ntilde putdup 8#121 /Oacute putdup 8#122 /Ocircumflex putdup 8#123 /Odieresis putdup 8#124 /Ograve putdup 8#125 /Otilde putdup 8#126 /Scaron putdup 8#127 /Uacute putdup 8#130 /Ucircumflex putdup 8#131 /Udieresis putdup 8#132 /Ugrave putdup 8#133 /Ydieresis putdup 8#134 /Zcaron putdup 8#135 /aacute putdup 8#136 /acircumflex putdup 8#137 /adieresis putdup 8#140 /agrave putdup 8#141 /aring putdup 8#142 /atilde putdup 8#143 /ccedilla putdup 8#144 /eacute putdup 8#145 /ecircumflex putdup 8#146 /edieresis putdup 8#147 /egrave putdup 8#150 /iacute putdup 8#151 /icircumflex putdup 8#152 /idieresis putdup 8#153 /igrave putdup 8#154 /ntilde putdup 8#155 /oacute putdup 8#156 /ocircumflex putdup 8#157 /odieresis putdup 8#160 /ograve putdup 8#161 /otilde putdup 8#162 /scaron putdup 8#163 /uacute putdup 8#164 /ucircumflex putdup 8#165 /udieresis putdup 8#166 /ugrave putdup 8#167 /ydieresis putdup 8#170 /zcaron putpop/Enc-dict 30 dict defEnc-dict /tmpstr1 50 string putEnc-dict /tmpstr2 50 string putEnc-dict /tmpstr3 50 string dup (Encoding-) exch cvs pop put/AEnc-def { % arguments: the original font's name, encoding nrEnc-dict begintmpstr2 cvs /Enc-no exch def % Remember the number in a stringdup /OrigName exch def % remember the namefindfont dup maxlength dict /newdict exch def % get dictionary for new font{ exch dup /FID ne { exch newdict 3 1 roll put } { pop pop } % Ignore FID ifelse} forallnewdict begin/Encoding tmpstr3 9 Enc-no putinterval tmpstr3 0 9 Enc-no length add getinterval cvn load def % Replace encodingcurrentdict /UniqueID known{ /UniqueID UniqueID Enc-no cvi 49999 mul add def } if % Derive New UniqueIDend % newdict/FNlength OrigName tmpstr1 cvs length def % convert name, remember lengthFNlength 1 add Enc-no length add stringdup 0 OrigName tmpstr1 cvs putintervaldup FNlength (-) putintervaldup FNlength 1 add Enc-no putintervaldup 0 tmpstr1 0 FNlength getinterval putinterval % Add old namecvn dup newdict /FontName 3 2 roll put newdict definefontend % Enc-dict} def/Times-Roman 1 AEnc-def pop/R-1{/Times-Roman-1 FF}def/R{/Times-Roman FF}def/B{/Times-Bold FF}def/I{/Times-Italic FF}def%%EndProlog%%Page: 1 1BP/slant 0 def/height 0 def480 V10 R720(MALLOC)S1154(\()S1196(3)S1254(\))S2696(Eighth)S(Edition)296 2989 A4693(MALLOC)S5127(\()S5169(3)S5227(\))S960 V9 R720(N)S722(NA)S790(AM)S858(ME)S940(E)S1080 V10 R1080(malloc,)S1404(free,)S1612(realloc,)S1937(calloc,)S2228(alloca)S10 R-12494(-)S10 R2576(memory)S2936(allocator)S1248 V9 R720(S)S722(SY)S774(YN)S842(NO)S910(OP)S978(PS)S1030(SI)S1082(IS)S1115(S)S1368 V10 B1080(#include)S1482(<sys/types.h>)S1488 V1080(#include)S1482(<stdlib.h>)S1608 V1080(#include)S1482(<alloca.h>)S1848 V1080(void)S1302(*malloc\(size_t)S10 I1950(size)S10 B2101(\))S1968 V1080(void)S(free\(void)387 1302 A1727(*)S10 I1777(ptr)S10 B1894(\))S2088 V1080(void)S1302(*realloc\(void)S1899(*)S10 I1949(ptr)S10 B2066(,)S2129(size_t)S10 I2408(size)S10 B2559(\))S2208 V1080(void)S1302(*calloc\(size_t)S10 I1911(nelem)S10 B2152(,)S2215(size_t)S10 I2494(elsize)S10 B2718(\))S2328 V1080(void)S1302(*alloca\(size_t)S10 I1916(size)S10 B2067(\))S2496 V9 R720(D)S722(DE)S790(ES)S848(SC)S900(CR)S962(RI)S1024(IP)S1057(PT)S1109(TI)S1167(IO)S1200(ON)S1268(N)S2616 V10 B1080(Malloc)S10 R1406(and)S10 B(free)169 1581 A10 R1780(provide)S2117(a)S2192(general-purpose)S2872(memory)S3238(allocation)S3666(package.)S10 B4077(Malloc)S10 R4404(returns)S4715(a)S4791(pointer)S5107(to)S5216(a)S2736 V1080(block)S1328(of)S1437(at)S1535(least)S10 I1745(size)S10 R1921(bytes)S2158(beginning)S2584(on)S2709(a)S2779(word)S(boundary.)404 3011 A2904 V1080(The)S1268(argument)S1679(to)S10 B(free)169 1788 A10 R1988(is)S2086(a)S2162(pointer)S2478(to)S2588(a)S2665(block)S2920(previously)S3376(allocated)S3772(by)S10 B3904(malloc)S10 R4189(;)S4249(this)S(space)224 4426 A4682(is)S4781(made)S5031(avail-)S3024 V1080(able)S1277(for)S1424(further)S1728(allocation,)S2179(but)S2336(its)S2460(contents)S2824(are)S2977(left)S(undisturbed.)499 3141 A3694(A)S3796(call)S3971(with)S4179(a)S4253(null)S10 I4438(ptr)S10 R4584(is)S4680(legal)S4904(and)S5077(does)S3144 V1080(nothing.)S3312 V1080(Needless)S1469(to)S1572(say,)S1756(grave)S2005(disorder)S(will)157 2360 A2542(result)S2791(if)S2878(the)S(space)224 3027 A3277(assigned)S3649(by)S10 B3775(malloc)S10 R4086(is)S4179(overrun)S4518(or)S4628(if)S4716(some)S(random)307 4954 A3432 V1080(number)S1412(is)S1504(handed)S1819(to)S10 B(free)169 1922 A10 R2091(.)S3600 V10 B1080(Malloc)S10 R1407(maintains)S(multiple)335 1829 A2195(lists)S2388(of)S2503(free)S2692(blocks)S(according)397 2985 A3413(to)S3522(size,)S3735(allocating)S(space)224 4163 A4419(from)S4647(the)S4802(appropriate)S3720 V1080(list.)S1288(It)S1385(calls)S10 B1605(sbrk)S10 R1836(\(see)S10 B2034(brk)S10 R2191(\(2\)\))S2378(to)S2491(get)S2649(more)S2891(memory)S3261(from)S3492(the)S3650(system)S3964(when)S4217(there)S4454(is)S4556(no)S4690(suitable)S(space)224 5037 A3840 V1080(already)S1402(free.)S4008 V10 B1080(Realloc)S10 R1427(changes)S1779(the)S1930(size)S2115(of)S2227(the)S2378(block)S2629(pointed)S2958(to)S3064(by)S10 I3192(ptr)S10 R3337(to)S10 I3443(size)S10 R3622(bytes)S3862(and)S4035(returns)S4343(a)S4416(pointer)S4729(to)S4835(the)S4987(\(possi-)S4128 V1080(bly)S1243(moved\))S1585(block.)S1893(The)S2085(contents)S(will)157 2454 A2645(be)S2774(unchanged)S3243(up)S3377(to)S3489(the)S3646(lesser)S3910(of)S4028(the)S4185(new)S4387(and)S4566(old)S4728(sizes.)S5008(A)S5115(call)S4248 V1080(with)S1284(a)S1354(null)S10 I1535(ptr)S10 R1677(is)S1769(legal)S1990(and)S2160(has)S2319(the)S2467(same)S2699(result)S2948(as)S10 B3057(malloc\()S10 I3376(size)S10 B3535(\))S10 R3569(.)S4416 V10 B1080(Calloc)S10 R1379(allocates)S(space)224 1757 A2006(for)S2149(an)S2269(array)S2502(of)S10 I2611(nelem)S10 R2877(elements)S3260(of)S3369(size)S10 I3551(elsize.)S10 R3825(The)S(space)224 4007 A4256(is)S(initialized)403 4348 A4776(to)S4879(zeros.)S4584 V10 B1080(Alloca)S10 R1382(allocates)S10 I1763(size)S10 R1942(bytes)S2182(of)S(space)224 2294 A2546(in)S2653(the)S2805(stack)S3041(frame)S3306(of)S3419(the)S3571(caller.)S3875(This)S4083(temporary)S(space)224 4526 A4779(is)S4875(automati-)S4704 V1080(cally)S1301(freed)S1534(on)S1659(return.)S4872 V1080(Each)S1314(of)S1430(the)S1585(allocation)S2014(routines)S2370(returns)S2682(a)S2759(pointer)S3076(to)S(space)224 3186 A3442(suitably)S3792(aligned)S4120(\(after)S4373(possible)S4735(pointer)S5053(coer-)S4992 V1080(cion\))S1312(for)S1455(storage)S1771(of)S1880(any)S2050(type)S2248(of)S2357(object.)S5160 V9 R720(S)S722(SE)S774(EE)S832(E)S928(A)S930(AL)S998(LS)S1056(SO)S1108(O)S5280 V10 B1080(brk)S10 R1237(\(2\).)S5448 V9 R720(D)S722(DI)S790(IA)S823(AG)S891(GN)S959(NO)S1027(OS)S1095(ST)S1147(TI)S1205(IC)S1238(CS)S1300(S)S5568 V10 B1080(Malloc)S10 R1376(,)S10 B1427(realloc)S10 R1744(and)S10 B1915(calloc)S10 R2187(return)S2455(a)S2527(null)S2710(pointer)S3022(if)S3111(there)S3340(is)S3434(no)S3561(available)S3952(memory)S4314(or)S4425(if)S4514(the)S4664(arena)S4910(has)S5071(been)S5688 V1080(detectably)S1519(corrupted)S1930(by)S2055(storing)S2359(outside)S2674(the)S(bounds)289 2822 A3136(of)S3245(a)S3315(block.)S5856 V9 R720(N)S722(NO)S790(OT)S858(TE)S916(ES)S974(S)S5976 V10 R1080(Other)S1335(implementations)S2030(of)S10 B2139(malloc)S10 R2424(,)S10 B2474(realloc)S10 R2790(or)S10 B2899(calloc)S10 R3170(may)S3368(return)S3634(a)S3704(null)S3885(pointer)S4196(if)S4284(the)S4433(size)S4616(of)S4726(the)S4875(requested)S6096 V1080(block)S1332(is)S1428(zero.)S1681(This)S1889(implementation)S(will)157 2549 A2735(always)S3044(return)S3314(a)S3388(zero)S3591(length)S3871(block)S4123(at)S4225(a)S4299(unique)S4600(address,)S4955(but)S(you)150 5111 A6216 V(should)267 1080 A1378(keep)S1599(in)S1708(mind)S1945(that)S2127(a)S2203(null)S2390(return)S2662(is)S2760(possible)S3120(if)S3213(the)S3367(program)S3739(is)S3837(run)S4002(to)S4111(another)S4445(system)S4756(and)S4933(that)S5116(this)S6336 V(should)267 1080 A1372(not)S1525(be)S1645(mistakenly)S2111(seen)S2315(as)S2424(an)S2544(error.)S6504 V9 R720(B)S722(BU)S784(UG)S852(GS)S920(S)S6624 V10 R1080(When)S10 B1345(realloc)S10 R1661(returns)S1966(a)S2036(null)S2217(pointer,)S2552(the)S2700(block)S2948(pointed)S3274(to)S3377(by)S10 I3502(ptr)S10 R3644(may)S3842(be)S3962(destroyed.)S6792 V10 B1080(Alloca)S10 R1379(is)S1471(machine)S1837(dependent;)S2303(its)S2423(use)S2582(is)S2674(discouraged.)S7903 V720(Page)S941(1)S2669(\()S2711(May)S2920(14,)S(1986)200 3070 A3278(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Trailer%%DocumentFonts: Times-Roman Times-Bold Times-Italic%%Pages: 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -