Correct type of third parameter. Don't include sys/types.h, define size_t.