static void dump(int argc, char **argv) { parse_options(NULL, NULL, &argc, &argv); if (argc != 1) die("wrong number of arguments"); const char *path = *argv; FILE *fp = fopen(path, "rb"); if (!fp) die("cannot open '%s':", path); struct halva *hv; int ret = hv_load_file(&hv, fp); fclose(fp); if (ret) die("cannot load lexicon: %s", hv_strerror(ret)); struct halva_iter itor; hv_iter_init(&itor, hv); const char *word; while ((word = hv_iter_next(&itor, NULL))) puts(word); if (ferror(stdout)) die("cannot dump lexicon:"); hv_free(hv); }
void cPrint_onMessage(HvBase *_c, const HvMessage *const m, const char *name) { if (Base(_c)->printHook != NULL) { char *s = msg_toString(m); Base(_c)->printHook(((double) msg_getTimestamp(m))/ctx_getSampleRate(_c), name, s, ctx_getUserData(_c)); hv_free(s); } }
void ctx_setBasePath(HvBase *const _c, const char *basePath) { hv_free(_c->basePath); if (basePath != NULL) { hv_size_t len = (hv_size_t) hv_strlen(basePath); _c->basePath = (char *) hv_malloc((len+1)*sizeof(char)); hv_strncpy(_c->basePath, basePath, len); } }
void mq_free(MessageQueue *q) { mq_clear(q); while (q->pool != NULL) { MessageNode *n = q->pool; q->pool = q->pool->next; hv_free(n); } mp_free(&q->mp); }
static void ml_free(MessagePoolList *ml) { if (ml != NULL) { while (ml_hasAvailable(ml)) { ml_pop(ml); } while (ml->pool != NULL) { MessageListNode *n = ml->pool; ml->pool = n->next; hv_free(n); } } }
void cPack_free(ControlPack *o) { hv_free(o->msg); }
void mp_free(MessagePool *mp) { hv_free(mp->buffer); for (int i = 0; i < MP_NUM_MESSAGE_LISTS; i++) { ml_free(&mp->lists[i]); } }
void sEnv_free(SignalEnvelope *o) { hv_free(o->hanningWeights); hv_free(o->buffer); }