X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mood.c;h=5d2d38b46637322ad93e802fce150b368cdae2e5;hp=354ce3ca43cb7afe03349e7969153d7743814be3;hb=3879481ddabc38236b9eee979a090c2a9bfa74d3;hpb=f652ce6afe7f6fd0e42814505234cbf4321a736e diff --git a/mood.c b/mood.c index 354ce3ca..5d2d38b4 100644 --- a/mood.c +++ b/mood.c @@ -77,6 +77,10 @@ struct mood { struct list_head score_list; }; +/* + * If current_mood is NULL then no mood is currently open. If + * current_mood->name is NULL, the dummy mood is currently open + */ static struct mood *current_mood; /** @@ -218,7 +222,8 @@ static void destroy_mood(struct mood *m) static struct mood *alloc_new_mood(const char *name) { struct mood *m = para_calloc(sizeof(struct mood)); - m->name = para_strdup(name); + if (name) + m->name = para_strdup(name); INIT_LIST_HEAD(&m->accept_list); INIT_LIST_HEAD(&m->deny_list); INIT_LIST_HEAD(&m->score_list); @@ -850,9 +855,9 @@ int change_current_mood(char *mood_name) return ret; close_current_mood(); current_mood = m; - } else { + } else { /* load dummy mood */ close_current_mood(); - current_mood = alloc_new_mood("dummy"); + current_mood = alloc_new_mood(NULL); } aa.m = current_mood; PARA_NOTICE_LOG("computing statistics of admissible files\n"); @@ -867,7 +872,7 @@ int change_current_mood(char *mood_name) if (ret < 0) goto out; } - PARA_NOTICE_LOG("loaded mood %s\n", current_mood->name); + PARA_NOTICE_LOG("loaded mood %s\n", mood_name? mood_name : "(dummy)"); ret = statistics.num; out: free(aa.array);