len should be a size_t not an int.