calloc.c

来自「KPIT GNU Tools is a set of GNU developme」· C语言 代码 · 共 70 行

C
70
字号
#ifdef MALLOC_PROVIDEDint _dummy_calloc = 1;#else/*FUNCTION<<calloc>>---allocate space for arraysINDEX	callocINDEX	_calloc_rANSI_SYNOPSIS	#include <stdlib.h>	void *calloc(size_t <[n]>, size_t <[s]>);	void *calloc_r(void *<[reent]>, size_t <n>, <size_t> <[s]>);	TRAD_SYNOPSIS	#include <stdlib.h>	char *calloc(<[n]>, <[s]>)	size_t <[n]>, <[s]>;	char *_calloc_r(<[reent]>, <[n]>, <[s]>)	char *<[reent]>;	size_t <[n]>;	size_t <[s]>;DESCRIPTIONUse <<calloc>> to request a block of memory sufficient to hold anarray of <[n]> elements, each of which has size <[s]>.The memory allocated by <<calloc>> comes out of the same memory poolused by <<malloc>>, but the memory block is initialized to all zerobytes.  (To avoid the overhead of initializing the space, use<<malloc>> instead.)The alternate function <<_calloc_r>> is reentrant.The extra argument <[reent]> is a pointer to a reentrancy structure.RETURNSIf successful, a pointer to the newly allocated space.If unsuccessful, <<NULL>>.PORTABILITY<<calloc>> is ANSI.Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,<<lseek>>, <<read>>, <<sbrk>>, <<write>>.*/#include <string.h>#include <stdlib.h>#ifndef _REENT_ONLY_PTR_DEFUN (calloc, (n, size),	size_t n _AND	size_t size){  return _calloc_r (_REENT, n, size);}#endif#endif /* MALLOC_PROVIDED */

⌨️ 快捷键说明

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