⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 malloc.3

📁 unix v7是最后一个广泛发布的研究型UNIX版本
💻 3
字号:
.TH MALLOC 3 .SH NAMEmalloc, free, realloc, calloc \- main memory allocator.SH SYNOPSIS.B char *malloc(size).br.B unsigned size;.PP.B free(ptr).br.B char *ptr;.PP.B char *realloc(ptr, size).br.B char *ptr;.br.B unsigned size;.PP.B char *calloc(nelem, elsize).br.B unsigned nelem, elsize;.SH DESCRIPTION.I Mallocand.I freeprovide a simple general-purpose memory allocation package..I Mallocreturns a pointer to a block of at least.I sizebytes beginning on a word boundary..PPThe argument to.I freeis a pointer to a block previously allocated by.IR malloc ;this space is made available for further allocation,but its contents are left undisturbed..PPNeedless to say, grave disorder will result if the spaceassigned by.I mallocis overrun or if some random number is handed to.IR free ..PP.I Mallocallocates the first big enough contiguous reach offree spacefound in a circular search from the last block allocated or freed,coalescing adjacent free blocks as it searches.It calls.I sbrk(see.IR break (2))to get more memory from the system when there is nosuitable space already free..PP.I Reallocchanges the size of the block pointed to by.I ptrto.I sizebytes and returns a pointer to the (possibly moved)block.The contents will be unchanged up to thelesser of the new and old sizes..PP.I Reallocalso works if.I ptrpoints to a block freed since the last call of.I malloc, reallocor.IR calloc ;thus sequences of.I free, mallocand.I realloccan exploit the search strategy of.I mallocto do storage compaction..PP.I Callocallocates space foran array of.I nelemelements of size.I elsize.The space is initialized to zeros..PPEach of the allocation routines returns a pointerto space suitably aligned (after possible pointer coercion)for storage of any type of object..SH DIAGNOSTICS.I Malloc, reallocand.I callocreturn a null pointer (0) if there is no available memoryor if the arena has been detectably corrupted by storing outside the boundsof a block..I Mallocmay be recompiled to check the arena very stringentlyon every transaction;see the source code..SH BUGSWhen.I reallocreturns 0,the blockpointed to by.I ptrmay be destroyed.

⌨️ 快捷键说明

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