+/* flense a buffer into a newly-allocated argument list */
+/* FIXME: handle quotes */
+static
+int buf_tok_vect_(char ***v, int *c, char *buf) {
+ const char *sep = " \t";
+ const size_t v_grow = 32;
+ size_t v_sz = 32;
+ char *st;
+
+ *c = 0;
+ *v = malloc(v_sz * sizeof **v);
+ if (*v == NULL) {
+ fprintf(stderr, "%s():%s\n", "malloc", strerror(errno));
+ return -1;
+ }
+
+ for ( (*v)[*c] = strtok_r(buf, sep, &st);
+ (*v)[*c];
+ (*v)[*c] = strtok_r(NULL, sep, &st)
+ ) {
+ (*c)++;
+
+ if ((size_t)(*c) == v_sz) {
+ void *tmp_ptr = realloc(*v, (v_sz + v_grow) * sizeof **v);
+ if (tmp_ptr == NULL) {
+ fprintf(stderr, "%s():%s\n", "realloc", strerror(errno));
+ free(*v);
+ *v = NULL;
+ return -1;
+ }
+ v_sz += v_grow;
+ }
+ }
+
+ return 0;
+}
+
+/* resets the instance and loads an image into ram starting at addr */