From: Krisztian Litkey Date: Thu, 6 Jun 2013 13:40:25 +0000 (+0300) Subject: simple-disambiguator: minor bugfixes. X-Git-Tag: submit/tizen/20130823.085041~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74fbb42dd77d8e80daf2986a4fe6c4040b2a9f72;p=profile%2Fivi%2Fspeech-recognition.git simple-disambiguator: minor bugfixes. --- diff --git a/src/plugins/simple-disambiguator/disambiguator.c b/src/plugins/simple-disambiguator/disambiguator.c index f01c932..aa7ae50 100644 --- a/src/plugins/simple-disambiguator/disambiguator.c +++ b/src/plugins/simple-disambiguator/disambiguator.c @@ -15,8 +15,8 @@ #define DISAMB_AUTHORS "Krisztian Litkey " #define DISAMB_VERSION "0.0.1" -#define MAX_DICT 256 -#define MAX_DEPTH 256 +#define MAX_DICT 256 /* max. dictionary name length */ +#define MAX_DEPTH 256 /* max. token tree depth */ typedef enum { @@ -34,8 +34,8 @@ typedef union { int index; /* command index */ } client; struct { /* for NODE_TYPE_DICTIONARY */ - srs_dict_op_t op; /* operation */ - char dict[MAX_DICT]; /* dictionary to switch or push */ + srs_dict_op_t op; /* operation */ + char *dict; /* dictionary to switch or push */ } dict; } node_data_t; @@ -204,7 +204,12 @@ static node_t *get_dictionary_node(node_t *prnt, const char *token, int insert) mrp_list_init(&node->children); node->type = NODE_TYPE_DICTIONARY; node->data.dict.op = op; - strcpy(node->data.dict.dict, dict); + node->data.dict.dict = mrp_strdup(dict); + + if (node->data.dict.dict == NULL) { + mrp_free(node); + return NULL; + } mrp_list_append(&prnt->children, &node->hook); @@ -406,10 +411,14 @@ static void free_all_nodes(node_t *root) switch (node->type) { case NODE_TYPE_TOKEN: - mrp_debug("freeing token node %s", node->data.token); + mrp_debug("freeing token node '%s'", node->data.token); mrp_free(node->data.token); break; + case NODE_TYPE_DICTIONARY: + mrp_debug("freeing dictionary node '%s'", node->data.dict.dict); + break; + default: break; } @@ -459,8 +468,6 @@ static int disambiguate(srs_srec_utterance_t *utt, mrp_list_hook_t *results, node_t *node, *child; int i, j, match; - MRP_UNUSED(dis); - mrp_list_init(results); mrp_debug("should disambiguate utterance %p", utt); @@ -563,9 +570,11 @@ static int config_disamb(srs_plugin_t *plugin, srs_cfg_t *settings) mrp_debug("configuring disambiguator"); n = srs_collect_config(settings, "disambiguator.", &cfg); + mrp_debug("found %d configuration keys%s", n, n ? ":" : ""); for (i = 0; i < n; i++) mrp_debug(" %s = %s", cfg[i].key, cfg[i].value); + srs_free_config(cfg); return TRUE;