fwrite.c

来自「在x86平台上运行不可信任代码的sandbox。」· C语言 代码 · 共 42 行

C
42
字号
#include <string.h>#include "ioprivate.h"size_t fwrite(const void *restrict buf, size_t eltsize, size_t nelts,		FILE *restrict f){	size_t totsize = eltsize * nelts;	// Check for space in the output buffer.	if (f->opos + totsize > f->omax) {		// Create/flush the output buffer.		if (__getospace(f) < 0)			return EOF;		if (totsize >= f->omax) {			// Bigger than the buffer - just write it directly.			if (__writebuf(f, buf, totsize) < 0)				return 0;			return nelts;		}	}	// Copy the data to the output buffer.	memcpy(&f->obuf[f->opos], buf, totsize);	f->opos += totsize;	// Flush the buffer if appropriate.	if ((f->bufmode == _IOLBF && memchr(buf, '\n', totsize)) ||			(f->bufmode == _IONBF)) {		if (fflush(f) < 0)			return 0;	}	return nelts;}

⌨️ 快捷键说明

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