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

📄 calloc.c

📁 标准c库代码,可以应用于各个系统提供了大量的基本函数
💻 C
字号:
/*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 functios <<_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){  register char *cp;  n *= size;  /* While it's tempting to have this call _malloc_r() instead, don't do it.     The application may have provided it's own malloc() and we want free()     (which will also be replaced) to properly free the buffer we allocate.  */  cp = malloc (n);  if (cp == 0)    return 0;  memset (cp, '\0', n);  return cp;}#endif

⌨️ 快捷键说明

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