From b0a87fd7b5aeb8007afd3ac25d8548543d42080c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 20 Mar 2022 21:53:44 +0100 Subject: [PATCH] mood.c: Rename struct mood to mood_instance. A mood is an blob object stored in the mood table. This structure describes something different, so name it accordingly. --- mood.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mood.c b/mood.c index 7b22f72d..9c2571aa 100644 --- a/mood.c +++ b/mood.c @@ -52,7 +52,7 @@ struct afs_statistics { * * A structure of this type is allocated and initialized at mood open time. */ -struct mood { +struct mood_instance { /** NULL means that this is the "dummy" mood. */ char *name; /** Bison's abstract syntax tree, used to determine admissibility. */ @@ -68,7 +68,7 @@ struct mood { * The statistics are adjusted dynamically through this pointer as files are * added, removed or played. */ -static struct mood *current_mood; +static struct mood_instance *current_mood; /* * Find the position of the most-significant set bit. @@ -127,7 +127,7 @@ __a_const static uint64_t int_sqrt(uint64_t x) return res; } -static void destroy_mood(struct mood *m) +static void destroy_mood(struct mood_instance *m) { if (!m) return; @@ -136,16 +136,18 @@ static void destroy_mood(struct mood *m) free(m); } -static struct mood *alloc_new_mood(const char *name) +static struct mood_instance *alloc_new_mood(const char *name) { - struct mood *m = zalloc(sizeof(struct mood)); + struct mood_instance *m = zalloc(sizeof(*m)); + if (name) m->name = para_strdup(name); m->stats.normalization_divisor = 1; return m; } -static int init_mood_parser(const char *mood_name, struct mood **m, char **err) +static int init_mood_parser(const char *mood_name, struct mood_instance **m, + char **err) { struct osl_object mood_def; int ret; @@ -175,7 +177,7 @@ static int check_mood(struct osl_row *mood_row, void *data) struct para_buffer *pb = data; char *mood_name, *errmsg; struct osl_object mood_def; - struct mood *m; + struct mood_instance *m; int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def); if (ret < 0) { @@ -346,7 +348,7 @@ static int del_afs_statistics(const struct osl_row *row) */ struct admissible_array { /** Files are admissible wrt. this mood. */ - struct mood *m; + struct mood_instance *m; /** The size of the array */ unsigned size; /** Pointer to the array of admissible files. */ @@ -521,7 +523,7 @@ static int mood_update_audio_file(const struct osl_row *aft_row, } /* sse: seconds since epoch. */ -static char *get_statistics(struct mood *m, int64_t sse) +static char *get_statistics(struct mood_instance *m, int64_t sse) { unsigned n = m->stats.num; int mean_days, sigma_days; -- 2.39.5