alloc.3

来自「UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱」· 3 代码 · 共 48 行

3
48
字号
.th ALLOC III 3/1/74.sh NAMEalloc, free \*- core allocator.sh SYNOPSIS.ft B.nfchar *alloc(size).s3free(ptr)char *ptr;.fi.ft R.sh DESCRIPTION.it Allocand.it freeprovide a simple general-purpose core management package..it Allocis given a size in bytes; it returns a pointerto an area at least that size whichis even and hence can hold an object of any type.The argument to.it freeis a pointer to an area previously allocated by.it alloc;this space is made available for further allocation..s3Needless to say, grave disorder will result if the spaceassigned by.it allocis overrun or if some random number is handed to.it free..s3The routine uses a first-fit algorithm whichcoalesces blocks being freed with otherblocks already free.It calls.it sbrk(see.it "break (II))"to get more core from the system when there is nosuitable space already free..sh DIAGNOSTICSReturns \*-1 if there is no available core..sh BUGSAllocated memory contains garbageinstead of being cleared.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?