Woo, C99 allows you to put variable definitions anywhere inside a function\!  Took advantage of this, with some concomitant (con-commit-ent, ho ho) code tidying.