fix `with_capacity` for zero-size vectors

A call to `malloc(0)` may return NULL, and this will be treated as
out-of-memory.