mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
parent
c3ed8d6c7f
commit
d769df3482
17 changed files with 102 additions and 155 deletions
|
@ -25,20 +25,14 @@
|
|||
* Writes data to stream.
|
||||
*
|
||||
* @param stride specifies the size of individual items
|
||||
* @param count is the number of strides to fetch
|
||||
* @param count is the number of strides to write
|
||||
* @return count on success, [0,count) on EOF, 0 on error or count==0
|
||||
*/
|
||||
size_t fwrite(const void *data, size_t stride, size_t count, FILE *f) {
|
||||
size_t i, n;
|
||||
const unsigned char *p;
|
||||
for (n = stride * count, p = data, i = 0; i < n; ++i) {
|
||||
if (fputc(p[i], f) == -1) {
|
||||
if (!(i % stride)) {
|
||||
return i / stride;
|
||||
} else {
|
||||
return __fseterr(f, EOVERFLOW);
|
||||
}
|
||||
}
|
||||
if (fputc(p[i], f) == -1) return -1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue