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

size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
  // FIXME: Check for overflow
  size_t bytes_to_read = nmemb * size;
  size_t rc = stream->read(stream, ptr, bytes_to_read);
  // On  success, fread() return the number of items read
  rc /= size;
  return rc;
}