1 #include "stdio_impl.h"
4 size_t __fwritex(const unsigned char *restrict s
, size_t l
, FILE *restrict f
)
8 if (!f
->wend
&& __towrite(f
)) return 0;
10 if (l
> f
->wend
- f
->wpos
) return f
->write(f
, s
, l
);
13 /* Match /^(.*\n|)/ */
14 for (i
=l
; i
&& s
[i
-1] != '\n'; i
--);
16 size_t n
= f
->write(f
, s
, i
);
23 memcpy(f
->wpos
, s
, l
);
28 size_t fwrite(const void *restrict src
, size_t size
, size_t nmemb
, FILE *restrict f
)
30 size_t k
, l
= size
*nmemb
;
33 k
= __fwritex(src
, l
, f
);
35 return k
==l
? nmemb
: k
/size
;
38 weak_alias(fwrite
, fwrite_unlocked
);