summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ac0e92)
raw | patch | inline | side by side (parent: 3ac0e92)
author | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:40 +0000 (19:11 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:40 +0000 (19:11 +0200) |
src/playlist.c | patch | blob | history | |
src/playlist.h | patch | blob | history |
diff --git a/src/playlist.c b/src/playlist.c
index d14f870b0902c0ef655a98b8e5216b29a50445f3..6751e5dad5870f1a3c9a1d647725fb4331e7a26f 100644 (file)
--- a/src/playlist.c
+++ b/src/playlist.c
{
playlist->id = 0;
playlist->updated = FALSE;
- playlist->list = g_array_sized_new(FALSE, FALSE,
- sizeof(struct mpd_song *), 1024);
+ playlist->list = g_ptr_array_sized_new(1024);
}
void
mpd_freeSong(song);
}
- g_array_set_size(playlist->list, 0);
+ g_ptr_array_set_size(playlist->list, 0);
}
gint
{
if (playlist->list != NULL) {
playlist_clear(playlist);
- g_array_free(playlist->list, TRUE);
+ g_ptr_array_free(playlist->list, TRUE);
}
memset(playlist, 0, sizeof(mpdclient_playlist_t));
diff --git a/src/playlist.h b/src/playlist.h
index 377ed84a2ee91e94a743e53a37c7f2cd5bf9ee7c..9cd88ab27c49c0cf84a68540f74899c680182f28 100644 (file)
--- a/src/playlist.h
+++ b/src/playlist.h
gboolean updated;
/* the list */
- GArray *list;
+ GPtrArray *list;
} mpdclient_playlist_t;
void
{
assert(idx < playlist_length(playlist));
- return g_array_index(playlist->list, struct mpd_song *, idx);
+ return g_ptr_array_index(playlist->list, idx);
}
static inline void
playlist_append(struct mpdclient_playlist *playlist, const mpd_Song *song)
{
- mpd_Song *song2 = mpd_songDup(song);
- g_array_append_val(playlist->list, song2);
+ g_ptr_array_add(playlist->list, mpd_songDup(song));
}
static inline void
{
assert(idx < playlist_length(playlist));
- g_array_index(playlist->list, mpd_Song *, idx) = mpd_songDup(song);
+ g_ptr_array_index(playlist->list, idx) = mpd_songDup(song);
}
static inline void
static inline void
playlist_remove(struct mpdclient_playlist *playlist, guint idx)
{
- mpd_Song *song = playlist_get(playlist, idx);
+ mpd_Song *song = g_ptr_array_remove_index(playlist->list, idx);
mpd_freeSong(song);
- g_array_remove_index(playlist->list, idx);
}
static inline void
song2->pos = n;
/* update the array */
- g_array_index(playlist->list, struct mpd_song *, idx1) = song2;
- g_array_index(playlist->list, struct mpd_song *, idx2) = song1;
+ g_ptr_array_index(playlist->list, idx1) = song2;
+ g_ptr_array_index(playlist->list, idx2) = song1;
}
struct mpd_song *playlist_lookup_song(struct mpdclient *c, gint id);