Oh wow, I had it wrong, your original order is correct. So it should be: 

```c
size_t to_delete = (new_len < old_len) ? (size_t)(old_len - new_len) : 0;
```

As you said. But at the end of the loop with statement:

```c
// to_delete = old_len - new_len
for (i = 0; i < old_len - new_len; i++) {
```

The value of `i` will be `old_len - new_len - 1` (unless `old_len - new_len == 0`), so `to_delete - 1`. Note that I'm not talking about what's correct, but about what's the same as the code you had before for subtracting extra:

```c
extra -= i;
// should be the same as
extra -= to_delete ? (to_delete - 1) : 0; 
```

Which, admittedly, looks kind of ugly...