1 /* mpdscribble (MPD Client)
2  * Copyright (C) 2008-2010 The Music Player Daemon Project
3  * Copyright (C) 2005-2008 Kuno Woudt <kuno@frob.nl>
4  * Project homepage: http://musicpd.org
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "record.h"
22 
23 #include <glib.h>
24 
25 void
record_copy(struct record * dest,const struct record * src)26 record_copy(struct record *dest, const struct record *src)
27 {
28 	dest->artist = g_strdup(src->artist);
29 	dest->track = g_strdup(src->track);
30 	dest->album = g_strdup(src->album);
31 	dest->number = g_strdup(src->number);
32 	dest->mbid = g_strdup(src->mbid);
33 	dest->time = g_strdup(src->time);
34 	dest->length = src->length;
35 	dest->love = src->love;
36 	dest->source = src->source;
37 }
38 
39 struct record *
record_dup(const struct record * src)40 record_dup(const struct record *src)
41 {
42 	struct record *dest = g_new(struct record, 1);
43 	record_copy(dest, src);
44 	return dest;
45 }
46 
47 void
record_deinit(struct record * record)48 record_deinit(struct record *record)
49 {
50 	g_free(record->artist);
51 	g_free(record->track);
52 	g_free(record->album);
53 	g_free(record->number);
54 	g_free(record->mbid);
55 	g_free(record->time);
56 }
57 
58 void
record_free(struct record * record)59 record_free(struct record *record)
60 {
61 	record_deinit(record);
62 	g_free(record);
63 }
64 
65 void
record_clear(struct record * record)66 record_clear(struct record *record)
67 {
68 	record->artist = NULL;
69 	record->track = NULL;
70 	record->album = NULL;
71 	record->number = NULL;
72 	record->mbid = NULL;
73 	record->time = NULL;
74 	record->length = 0;
75 	record->love = false;
76 	record->source = "P";
77 }
78