Create chunk.c

Copy function source from the header.