Switch to using size_t rather than uint32 for lengths, to support buffers >= 4GiB