General observation: shouldn't that be `size_t len`?