summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fwrite.c
blob: 6065465f636fd596a98734fd04fc6dfffda17b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <sys/types.h>

size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
  // FIXME: Check for overflow
  size_t bytes_to_write = nmemb * size;
  size_t rc = stream->write(stream, ptr, bytes_to_write);
  // On  success, fwrite() return the number of items
  // written.
  rc /= size;
  return rc;
}