forsyth20121205-174063a80cc13 years agoHistory
81 lines · 1.6 KB · Text
RawDownload
.TH MALLOC 10.2.SH NAMEmalloc, mallocz, smalloc, free, realloc, calloc \- kernel memory allocators.SH SYNOPSIS.ta \w'\fLvoid* 'u.Bvoid*	malloc(ulong size).PP.Bvoid*	mallocz(ulong size, int clr).PP.Bvoid*	smalloc(ulong size).PP.Bvoid*	realloc(void *p, ulong size).PP.Bvoid*	calloc(ulong n, ulong szelem).PP.Bvoid	free(void *p).SH DESCRIPTIONThese functions allocate memory from the.B mainmemmemory pool.All but.I smalloc(which sleeps)may safely be called by interrupt handlers..PP.I Mallocreturns a pointer to a block of at least.I sizebytes, initialised to zero.The result is aligned on a 32-bit boundary..I Malloczis similar, but only clears the memory if.I clris non-zero..PP.I Smallocreturns a pointer to a block of.I sizebytes, initialised to zero.If the memory is not immediately available,.I smallocretries every 100 milliseconds until the memory is acquired..PP.I Callocreturns a pointer to a block of memory of at least.I "n*szelem"bytes, initialised to zero..PP.I Reallocchanges the size of the block pointed to by.I pto.I sizebytes,if possible without moving the data,and returns a pointer to the block.The contents are unchanged up to the lesser of old and new sizes,and any new space allocated is initialised to zero.If.I pis a null pointer,.I reallocreturns the equivalent of.BR "malloc(size)" ..PPThe argument to.I freeis a pointer to a block of memory allocated by one of the routines above, whichis returned to the allocation pool, or a null pointer, which is ignored..SH DIAGNOSTICSAll functions except.I smallocreturn a null pointer if space is unavailable..SH SEE ALSO.IR xalloc (10.2)