X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=74b00d35b2ddc4efd07f2e8783d1a37fcc3117b4;hb=ff47d38b16a15f57ac8804ae599c8d020de8b2f3;hp=e905f92cc64b4e99d55691d3d9e5805e3f3985d1;hpb=ab0ccdfcabd85453d155f913a8024f0be38e427e;p=paraslash.git diff --git a/mood.c b/mood.c index e905f92c..74b00d35 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);