📄 libmpalloc.ps
字号:
-.219(NA)72 84 S(ME).219 E F0(libmpalloc \255 dynamic memory allocation replacement library)108 96 QF1(SYNOPSIS)72 112.8 Q F0(#include <mpalloc.h>)108 124.8 Q -.2(vo)108148.8 S(id *MP_MALLOC\(v).2 E(oid *ptr)-.2 E 2.5(,s)-.4 G(ize_t count, typename type\);)-2.5 E -.2(vo)108 160.8 S(id *MP_CALLOC\(v).2 E(oid *ptr)-.2 E 2.5(,s)-.4 G(ize_t count, typename type\);)-2.5 E(char *MP_STRDUP\(char *ptr)108172.8 Q 2.5(,c)-.4 G(onst char *str\);)-2.5 E -.2(vo)108 184.8 S(id *MP_REALLOC\(v).2 E(oid *ptr)-.2 E 2.5(,s)-.4 G(ize_t count, typename type\);)-2.5 E -.2(vo)108 196.8 S(id MP_FREE\(v).2 E(oid *ptr\);)-.2 E(__mp_f)108 208.8 Q(ailhandler MP_F)-.1 E(AILURE\(__mp_f)-.74 E(ailhandler func\);)-.1 E F1(DESCRIPTION)72 225.6Q F0(The)108 237.6 Q/F2 10/Times-Italic@0 SF .432(mpalloc libr)2.932 F(ary)-.15 E F0 .432(contains release implementations of all of the mpat\rol library functions, with all of its)2.932 F .498(checking, deb)108249.6 R .498(ugging and tracing features disabled.)-.2 F .499(It is fully link-compatible with the mpatrol library and)5.498 F 1.473(so can be link)108 261.6 R 1.473(ed in instead of the mpatrol library \in order to quickly disable all of its features without)-.1 F .614(requ\iring a complete recompilation of all of the source \214les in a projec\t.)108 273.6 R .615(It also contains implementations)5.615 F(of the)108285.6 Q/F3 10/Times-Bold@0 SF(MP_MALLOC)2.5 E F0 -.1(fa)2.5 G(mily of functions that can be used in a release en).1 E(vironment.)-.4E .414(All of the function de\214nitions in)108 302.4 R F2(mpatr)2.913 E(ol.h)-.45 E F0 .413(can be disabled by de\214ning the)2.913 F F3(NDEB)2.913 E(UG)-.1 E F0 .413(preprocessor macro,)2.913 F .285(which is the same macro used to control the beha)108 314.4 R .286(viour of the)-.2 F F3(assert)2.786 E F0 2.786(function. If)2.786 F F3(NDEB)2.786 E(UG)-.1 E F0 .286(is de\214ned then)2.786 F .548(no macro rede\214nition of functions will tak)108 326.4 R 3.048(ep)-.1G .548(lace and all special mpatrol library functions will e)-3.048 F-.25(va)-.25 G .548(luate to).25 F .067(empty statements.)108 338.4 R(The)5.067 E F2(mpalloc.h)2.567 E F0 .067(header \214le will also be included in this case.)2.567 F .068(It is intended that the)5.067 F F3(NDE-)2.568 E -.1(BU)108 350.4 S(G).1E F0(preprocessor macro be de\214ned in release b)2.5 E(uilds.)-.2 E.227(The mpalloc library contains functional replacements for all of th\e mpatrol library')108 367.2 R 2.727(sd)-.55 G .227(ynamic memory allo-)-2.727 F .87(cation and memory operation functions, mainly for use in s\ituations where not all of the source \214les in a)108 379.2 R .935(project ha)108 391.2 R 1.235 -.15(ve b)-.2 H .935(een recompiled with the).15 F F3(NDEB)3.435 E(UG)-.1 E F0 .935(preprocessor macro in order to remo)3.435 F 1.235 -.15(ve m)-.15 H3.435(patrol. Ho).15 F(w-)-.25 E -2.15 -.25(ev e)108 403.2 T 1.652 -.4(r, n).25 H .852(ot all of these functions can be fully implemented usi\ng ANSI C and so may contain some limita-).4 F 3.359(tions. The)108415.2 R .858(only recommended solution for a \214nal release is to perf\orm a complete recompile with)3.359 F F3(NDE-)3.358 E -.1(BU)108 427.2 S(G).1 E F0(de\214ned.)2.5 E F1(FUNCTIONS)72 444 Q F0 .542(The follo)108456 R .542(wing 6 functions are pro)-.25 F .543(vided as con)-.15 F -.15(ve)-.4 G .543(nient alternati).15 F -.15(ve)-.25 G 3.043(st).15 G 3.043(ot)-3.043 G .543(he ANSI C dynamic memory alloca-)-3.043 F .165(tion functions \(although)108 468 R F3(strdup)2.665 E F0 .165(is not strictly an ANSI C function\).)2.665 F(The)5.164 E 2.664(ya)-.15G .164(re implemented as preprocessor)-2.664 F .07(macro functions which may e)108 480 R -.25(va)-.25 G .07(luate their ar).25 F .071(guments more than once, so e)-.18 F .071(xtra care should be tak)-.15 F .071(en to a)-.1 F -.2(vo)-.2 G(id).2 E1.141(passing ar)108 492 R 1.141(guments with side-ef)-.18 F 3.641(fects. None)-.25 F 1.141(of the functions return)3.641 F F3(NULL)3.641E F0 1.14(if no memory is a)3.641 F -.25(va)-.2 G 1.14(ilable and).25 F.791(instead abort the program with a useful error message indicating w\here the call to allocate memory came)108 504 R(from and what w)108 516Q(as being allocated.)-.1 E 1.6 -.8(To u)5 H(se these you should include the).8 E F2(mpalloc.h)2.5 E F0(header \214le:)2.5 E F3(MP_MALLOC)108 532.8 Q F0(Allocates)144 544.8 QF2(count)3.183 E F0 .683(uninitialised items of type)3.183 F F2(type)3.183 E F0 .682(from the heap, sets)3.182 F F2(ptr)3.182 E F0 .682(to the result and returns a)3.182 F 2.137(suitably-cast pointer to the \214rst item of the allocation.)144 556.8R 2.137(The pointer returned will be suitably)7.137 F .551(aligned for holding items of type)144 568.8 R F2(type)3.051 E F0 5.551(.I)C(f)-5.551 E F2(count)3.051 E F0(is)3.051 E F2(0)3.051 E F0 .551(then it will be implicitly rounded up to)3.051 F F2(1)3.051 E F0 5.551(.I)C(f)-5.551 E .472(there is not enough space in the heap then the pr\ogram will be aborted after calling the allocation)144 580.8 R -.1(fa)144 592.8 S 1.57(ilure handler).1 F 4.07(,w)-.4 G 1.57(hich by def)-4.07F 1.57(ault writes an appropriate error message to the standard error \214le)-.1 F 3.884(stream. The)144 604.8 R 1.384(allocated memory in)3.884 F F2(ptr)3.884 E F0 1.385(must be deallocated with)3.885 F F3(MP_FREE)3.885E F0 1.385(or reallocated with)3.885 F F3(MP_REALLOC)144 616.8 Q F0(.)AF3(MP_CALLOC)108 633.6 Q F0(Allocates)144 645.6 Q F2(count)2.563 E F0.063(zero-initialised items of type)2.563 F F2(type)2.563 E F0 .062(from the heap, sets)2.562 F F2(ptr)2.562 E F0 .062(to the result and returns a)2.562 F 2.137(suitably-cast pointer to the \214rst item of the allocation.)144 657.6R 2.137(The pointer returned will be suitably)7.137 F .551(aligned for holding items of type)144 669.6 R F2(type)3.051 E F0 5.551(.I)C(f)-5.551 E F2(count)3.051 E F0(is)3.051 E F2(0)3.051 E F0 .551(then it will be implicitly rounded up to)3.051 F F2(1)3.051 E F0 5.551(.I)C(f)-5.551 E .472(there is not enough space in the heap then the pr\ogram will be aborted after calling the allocation)144 681.6 R -.1(fa)144 693.6 S 1.57(ilure handler).1 F 4.07(,w)-.4 G 1.57(hich by def)-4.07F 1.57(ault writes an appropriate error message to the standard error \214le)-.1 F 3.884(stream. The)144 705.6 R 1.384(allocated memory in)3.884 F F2(ptr)3.884 E F0 1.385(must be deallocated with)3.885 F F3(MP_FREE)3.885E F0 1.385(or reallocated with)3.885 F F3(MP_REALLOC)144 717.6 Q F0(.)A(Release 1.4)72 768 Q 2.5(8J)157.35 G(anuary 2002)-2.5 E(1)198.45 E EP%%Page: 2 2%%BeginPageSetupBP%%EndPageSetup/F0 10/Times-Roman@0 SF(LIBMP)72 48 Q 126.735(ALLOC\(3\) mpatrol)-.92 F126.735(library LIBMP)2.5 F(ALLOC\(3\))-.92 E/F1 10/Times-Bold@0 SF(MP_STRDUP)108 84 Q F0 1.267(Allocates e)144 96 R 1.267(xactly enough memory from the heap to duplicate)-.15 F/F2 10/Times-Italic@0 SF(str)3.767 E F0 1.267(\(including the terminating nul)3.767 F .225(character\), sets)144 108 R F2(ptr)2.725 E F0 .226(to the \result and returns a suitably-cast pointer to the \214rst byte of the a\llocation)2.726 F 1.532(after cop)144 120 R(ying)-.1 E F2(str)4.032 E F01.532(to the ne)4.032 F 1.532(wly-allocated memory)-.25 F 6.532(.T)-.65G 1.531(he pointer returned will ha)-6.532 F 1.831 -.15(ve n)-.2 H 4.031(oa).15 G(lignment)-4.031 E .744(constraints and can be used to store c\haracter data up to the length of)144 132 R F2(str)3.244 E F0 5.744(.I)C3.244(ft)-5.744 G .744(here is not enough)-3.244 F 1.587(space in the h\eap then the program will be aborted after calling the allocation f)144144 R 1.587(ailure handler)-.1 F(,)-.4 E .802(which by def)144 156 R.802(ault writes an appropriate error message to the standard error \\214le stream.)-.1 F .802(The allo-)5.802 F(cated memory in)144 168 Q F2(ptr)2.5 E F0(must be deallocated with)2.5 E F1(MP_FREE)2.5 E F0(or reallocated with)2.5 E F1(MP_REALLOC)2.5 E F0(.)A F1(MP_REALLOC)108184.8 Q F0 .387(Resizes the memory allocation be)144 196.8 R .387(ginning at)-.15 F F2(ptr)2.887 E F0(to)2.887 E F2(count)2.887 E F0 .387(items of type)2.887 F F2(type)2.887 E F0 .386(and returns a suitably-)2.887 F .092(cast pointer to the \214rst item of the ne)144 208.8 R2.592(wa)-.25 G .092(llocation after cop)-2.592 F(ying)-.1 E F2(ptr)2.592 E F0 .092(to the ne)2.592 F .092(wly-allocated memory)-.25 F(,)-.65 E .101(which will be truncated if)144 220.8 R F2(count)2.601 E F0.101(is smaller than the original number of items.)2.601 F .1(The pointer returned)5.1 F .228(will be suitably aligned for holding items of type)144 232.8 R F2(type)2.728 E F0 5.228(.I)C(f)-5.228 E F2(ptr)2.728 E F0(is)2.728 E F1(NULL)2.728 E F0 .228(then the call will be equi)2.728 F(v-)-.25 E 1.662(alent to)144 244.8 R F1(MP_MALLOC)4.162 E F0 6.661(.I)C(f)-6.661 E F2(count)4.161 E F0(is)4.161 E F2(0)4.161 E F0 1.661(then it will be implicitly rounded up to)4.161 F F2(1)4.161 E F0 6.661(.I)C(f)-6.661 E F2(count)4.161 E F0(is)4.161 E 1.69(greater than the original number of items then the e)144 256.8 R 1.691(xtra space will be \214lled with uninitialised)-.15 F 3.178(bytes. If)144 268.8 R .677(there is not enough space in the heap then the program\ will be aborted after calling the)3.178 F 1.326(allocation f)144 280.8R 1.327(ailure handler)-.1 F 3.827(,w)-.4 G 1.327(hich by def)-3.827 F1.327(ault writes an appropriate error message to the standard)-.1 F.633(error \214le stream.)144 292.8 R .633(The allocated memory must be deallocated with)5.633 F F1(MP_FREE)3.133E F0 .632(and can be reallo-)3.133 F(cated ag)144 304.8 Q(ain with)-.05E F1(MP_REALLOC)2.5 E F0(.)A F1(MP_FREE)108 321.6 Q F0 .218(Frees the memory allocation be)144 333.6 R .218(ginning at)-.15 F F2(ptr)2.718 E F0 .218(so the memory can be reused by another call to allo-)2.718 F .923(cate memory)144 345.6 R 3.423(,a)-.65 G .923(nd sets)-3.423 F F2(ptr)3.423 E F0(to)3.423 E F1(NULL)3.423 E F0 .922(after freeing the memory)3.422 F 5.922(.I)-.65 G(f)-5.922 E F2(ptr)3.422 E F0(is)3.422 E F1(NULL)3.422 E F0 .922(then no memory)3.422 F(will be freed.)144 357.6 Q F1(MP_F)108 374.4 Q(AILURE)-.9 E F0 1.504(Installs an allocation f)144386.4 R 1.504(ailure handler speci\214cally for use with)-.1 F F1(MP_MALLOC)4.004 E F0(,)A F1(MP_CALLOC)4.004 E F0(,)A F1(MP_STRDUP)144398.4 Q F0(and)2.635 E F1(MP_REALLOC)2.635 E F0 .135(and returns a pointer to the pre)2.635 F .135(viously installed handler)-.25 F 2.635(,n)-.4 G(or)-2.635 E(-)-.2 E.886(mally the def)144 410.4 R .886(ault handler if no handler had been pre)-.1 F .886(viously installed.)-.25 F .887(This will be called by the)5.886 F(abo)144 422.4 Q 1.566-.15(ve f)-.15 H 1.266(unctions when there is not enough space in the h\eap for them to satisfy their allocation).15 F 3.689(request. The)144434.4 R(def)3.689 E 1.189(ault allocation f)-.1 F 1.189(ailure handler will terminate the program after writing an error)-.1 F1.77(message to the standard error \214le stream indicating where the o\riginal allocation request took)144 446.4 R(place and what w)144 458.4 Q(as being allocated.)-.1 E/F3 10.95/Times-Bold@0 SF(SEE ALSO)72 475.2 QF1(mpatr)108 487.2 Q(ol)-.18 E F0(\(1\),)A F1(mpr)3.673 E(of)-.18 E F0(\(1\),)A F1(mptrace)3.673 E F0(\(1\),)A F1(mleak)3.674 E F0(\(1\),)A F1(mpsym)3.674 E F0(\(1\),)A F1(mpedit)3.674 E F0(\(1\),)A F1(hexw)3.674 E(ords)-.1 E F0(\(1\),)A F1(libmpatr)3.674 E(ol)-.18 E F0(\(3\),)A F1(mal-)3.674 E(loc)108 499.2 Q F0(\(3\),)A F1(assert)2.5 E F0(\(3\).)A(The mpatrol manual and reference card.)108 516 Q(http://www)108 532.8 Q(.cbmamig)-.65 E(a.demon.co.uk/mpatrol/)-.05 E F3 -.548(AU)72 549.6 S(THOR).548 E F0(Graeme S. Ro)108 561.6 Q 2.5(y<)-.1 G(graeme.ro)-2.5 E(y@analog.com>)-.1 E F3(COPYRIGHT)72 578.4 Q F0(Cop)108 590.4 Q(yright \(C\) 1997-2002 Graeme S. Ro)-.1 E 2.5(y<)-.1 G(graeme.ro)-2.5 E(y@analog.com>)-.1 E .78(This library is free softw)108 607.2 R .78(are; you can redistrib)-.1 F .78(ute it and/or modify it under the terms of the GNU Library)-.2 F .797(General Public License as published by the Free Softw)108 619.2 R .797(are F)-.1 F .797(oundation; either v)-.15 F .797(ersion 2 of the License, or)-.15 F(\(at your option\) an)108 631.2 Q2.5(yl)-.15 G(ater v)-2.5 E(ersion.)-.15 E 1.031(This library is distrib)108 648 R 1.031(uted in the hope that it will be useful, b)-.2 F 1.03(ut WITHOUT ANY W)-.2 F(ARRANTY)-1.2 E 3.53(;w)-.92 G(ithout)-3.53 E -2.15 -.25(ev e)108660 T 2.729(nt).25 G .229(he implied w)-2.729 F .229(arranty of MERCHANT)-.1 F .229(ABILITY or FITNESS FOR A P)-.93 F(AR)-.92 E .23(TICULAR PURPOSE.)-.6 F(See)5.23 E(the GNU Library General Public License for more details.)108 672 Q -1.1(Yo)108 688.8 S 2.647(us)1.1 G .147(hould ha)-2.647 F .447 -.15(ve r)-.2H(ecei).15 E -.15(ve)-.25 G 2.647(dac).15 G(op)-2.647 E 2.647(yo)-.1 G2.647(ft)-2.647 G .146(he GNU Library General Public License along with this library; if not,)-2.647 F(write to the Free Softw)108 700.8 Q(are F)-.1 E(oundation, Inc., 59 T)-.15 E(emple Place, Suite 330, Boston, MA 02111-1307, USA.)-.7 E(Release 1.4)72 768 Q 2.5(8J)157.35 G(anuary 2002)-2.5 E(2)198.45 E EP%%Trailerend%%EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -