X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=a535bdcfe2c5c1dd74470bb3f11ccdeda3e9e01f;hb=9c4691036a9f8999ec19034fb218e8fcdc393475;hp=b3f007b68fe07c46f500d1aaa7dffdfe9503f451;hpb=26243a4b963bc3c59020b0469f1e469025da0ad8;p=paraslash.git diff --git a/mood.c b/mood.c index b3f007b6..a535bdcf 100644 --- a/mood.c +++ b/mood.c @@ -119,14 +119,6 @@ __a_const static uint64_t int_sqrt(uint64_t x) return res; } -/* returns 1 if row admissible, 0 if not, negative on errors */ -static int row_is_admissible(const struct osl_row *aft_row, struct mood *m) -{ - if (!m) - return -E_NO_MOOD; - return mp_eval_row(aft_row, m->parser_context); -} - static void destroy_mood(struct mood *m) { if (!m) @@ -138,7 +130,7 @@ static void destroy_mood(struct mood *m) static struct mood *alloc_new_mood(const char *name) { - struct mood *m = para_calloc(sizeof(struct mood)); + struct mood *m = zalloc(sizeof(struct mood)); if (name) m->name = para_strdup(name); return m; @@ -355,16 +347,14 @@ struct admissible_array { static int add_if_admissible(struct osl_row *aft_row, void *data) { struct admissible_array *aa = data; - int ret; - ret = row_is_admissible(aft_row, aa->m); - if (ret <= 0) - return ret; + if (!mp_eval_row(aft_row, aa->m->parser_context)) + return 0; if (statistics.num >= aa->size) { aa->size *= 2; aa->size += 100; - aa->array = para_realloc(aa->array, - aa->size * sizeof(struct osl_row *)); + aa->array = arr_realloc(aa->array, aa->size, + sizeof(struct osl_row *)); } aa->array[statistics.num] = aft_row; return add_afs_statistics(aft_row); @@ -500,10 +490,7 @@ static int mood_update_audio_file(const struct osl_row *aft_row, if (ret < 0) return ret; was_admissible = ret; - ret = row_is_admissible(aft_row, current_mood); - if (ret < 0) - return ret; - is_admissible = (ret > 0); + is_admissible = mp_eval_row(aft_row, current_mood->parser_context); if (!was_admissible && !is_admissible) return 1; if (was_admissible && !is_admissible) @@ -685,19 +672,16 @@ out: * This function is called on events which render the current list of * admissible files useless, for example if an attribute is removed from the * attribute table. - * - * If no mood is currently open, the function returns success. */ static int reload_current_mood(void) { int ret; char *mood_name = NULL; + assert(current_mood); ret = clear_score_table(); if (ret < 0) return ret; - if (!current_mood) - return 1; PARA_NOTICE_LOG("reloading %s\n", current_mood->name? current_mood->name : "(dummy)"); if (current_mood->name)