song: converted "type" to enum

Having an enum type is much nicer than an anonymous integer plus CPP
macros.  Note that the old code didn't save any space by declaring the
variable 8 bit, due to padding.
This commit is contained in:
Max Kellermann 2008-09-29 15:52:30 +02:00
parent e8e9438255
commit 35d519625d
2 changed files with 8 additions and 5 deletions

View File

@ -40,7 +40,7 @@ Song *newNullSong(void)
return song;
}
Song *newSong(const char *url, int type, Directory * parentDir)
Song *newSong(const char *url, enum song_type type, Directory * parentDir)
{
Song *song;

View File

@ -25,8 +25,10 @@
#define SONG_BEGIN "songList begin"
#define SONG_END "songList end"
#define SONG_TYPE_FILE 1
#define SONG_TYPE_URL 2
enum song_type {
SONG_TYPE_FILE = 1,
SONG_TYPE_URL = 2
};
#define SONG_FILE "file: "
#define SONG_TIME "Time: "
@ -35,7 +37,7 @@ struct client;
typedef struct _Song {
char *url;
int8_t type;
enum song_type type;
struct tag *tag;
struct _Directory *parentDir;
time_t mtime;
@ -43,7 +45,8 @@ typedef struct _Song {
Song *newNullSong(void);
Song *newSong(const char *url, int songType, struct _Directory *parentDir);
Song *newSong(const char *url, enum song_type type,
struct _Directory *parentDir);
void freeSong(Song *);