use ssize_t for index and capacity