X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mood.c;h=5d2d38b46637322ad93e802fce150b368cdae2e5;hp=e905f92cc64b4e99d55691d3d9e5805e3f3985d1;hb=e065f3eec9be99d82da855bf3da38d8e86752fef;hpb=02dd632ab2a6696aff7b6c6d108069704cfe871a diff --git a/mood.c b/mood.c index e905f92c..5d2d38b4 100644 --- a/mood.c +++ b/mood.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2012 Andre Noll + * Copyright (C) 2007-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -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);