summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-02 18:45:49 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-02 18:45:49 +0200
commit91e6c9743f449c64351fff801e2abd528ebdcd4b (patch)
tree3c430727d2b6ae8bee9bf6cff70da306da7deb3c /plugins
parentab9f5abcf64ed36193f270d621c06c4b8fd5e82d (diff)
fixed ton of memleaks and memory-related crashes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/adplug/adplug-db.cpp1
-rw-r--r--plugins/cdda/cdda.c18
-rw-r--r--plugins/ffap/ffap.c7
-rw-r--r--plugins/ffmpeg/ffmpeg.c1
-rw-r--r--plugins/flac/flac.c1
-rw-r--r--plugins/gtkui/ddblistview.c12
-rw-r--r--plugins/gtkui/fileman.c3
-rw-r--r--plugins/mpgmad/mpgmad.c6
-rw-r--r--plugins/sid/csid.cpp1
-rw-r--r--plugins/sndfile/sndfile.c1
-rw-r--r--plugins/vorbis/vorbis.c2
-rw-r--r--plugins/vtx/vtx.c1
-rw-r--r--plugins/wavpack/wavpack.c1
13 files changed, 40 insertions, 15 deletions
diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp
index b97a42da..c0c9699b 100644
--- a/plugins/adplug/adplug-db.cpp
+++ b/plugins/adplug/adplug-db.cpp
@@ -262,6 +262,7 @@ adplug_insert (DB_playItem_t *after, const char *fname) {
}
// insert
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
}
// free decoder
diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c
index b7bc2598..4632be3f 100644
--- a/plugins/cdda/cdda.c
+++ b/plugins/cdda/cdda.c
@@ -342,6 +342,7 @@ cddb_thread (void *items_i)
snprintf (tmp, sizeof (tmp), "%02d", trk);
deadbeef->pl_add_meta (items[i], "track", tmp);
deadbeef->sendmessage (M_TRACKCHANGED, 0, idx, 0);
+ deadbeef->pl_item_unref (items[i]);
}
cddb_disc_destroy (disc);
deadbeef->mutex_unlock (mutex);
@@ -394,13 +395,23 @@ cda_insert (DB_playItem_t *after, const char *fname) {
struct cddb_thread_params *p = malloc (sizeof (struct cddb_thread_params));
memset (p, 0, sizeof (struct cddb_thread_params));
p->cdio = cdio;
+
+ int enable_cddb = deadbeef->conf_get_int ("cdda.freedb.enable", DEFAULT_USE_CDDB);
+
for (i = 0; i < tracks; i++)
{
res = insert_single_track (cdio, res, is_image ? fname : NULL, i+first_track);
- p->items[i] = res;
+ if (res) {
+ if (enable_cddb) {
+ p->items[i] = res;
+ }
+ else {
+ deadbeef->pl_item_unref (res);
+ }
+ }
}
trace ("cdda: querying freedb...\n");
- if (deadbeef->conf_get_int ("cdda.freedb.enable", DEFAULT_USE_CDDB)) {
+ if (enable_cddb) {
if (cddb_tid) {
deadbeef->thread_join (cddb_tid);
}
@@ -411,6 +422,9 @@ cda_insert (DB_playItem_t *after, const char *fname) {
{
track_nr = atoi (shortname);
res = insert_single_track (cdio, after, NULL, track_nr);
+ if (res) {
+ deadbeef->pl_item_unref (res);
+ }
cdio_destroy (cdio);
}
return res;
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index f1ffdca6..4f496ec5 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -37,10 +37,10 @@
#include <assert.h>
#include "../../deadbeef.h"
-#define ENABLE_DEBUG 1
+#define ENABLE_DEBUG 0
-#define trace(...) { fprintf(stderr, __VA_ARGS__); }
-//#define trace(fmt,...)
+//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+#define trace(fmt,...)
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
@@ -1750,6 +1750,7 @@ ffap_insert (DB_playItem_t *after, const char *fname) {
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c
index ee723238..e157fd45 100644
--- a/plugins/ffmpeg/ffmpeg.c
+++ b/plugins/ffmpeg/ffmpeg.c
@@ -508,6 +508,7 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) {
}
// now the track is ready, insert into playlist
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index 0c6d232f..9281b62e 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -704,6 +704,7 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
goto cflac_insert_fail;
}
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
if (info.file) {
deadbeef->fclose (info.file);
}
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 7d30e464..845758a0 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -51,7 +51,7 @@
#define PL_NEXT(it) (ps->binding->next (it))
#define PL_PREV(it) (ps->binding->prev (it))
-#define REF(it) {if (it) ps->binding->ref (it);}
+//#define REF(it) {if (it) ps->binding->ref (it);}
#define UNREF(it) {if (it) ps->binding->unref(it);}
// HACK!!
@@ -88,6 +88,8 @@ static void ddb_listview_init(DdbListview *listview);
static void ddb_listview_destroy(GtkObject *object);
// fwd decls
+void
+ddb_listview_free_groups (DdbListview *listview);
static inline void
draw_drawable (GdkDrawable *window, GdkGC *gc, GdkDrawable *drawable, int x1, int y1, int x2, int y2, int w, int h);
@@ -449,6 +451,9 @@ ddb_listview_destroy(GtkObject *object)
g_return_if_fail(DDB_IS_LISTVIEW(object));
listview = DDB_LISTVIEW(object);
+
+ ddb_listview_free_groups (listview);
+
while (listview->columns) {
DdbListviewColumn *next = listview->columns->next;
ddb_listview_column_free (listview, listview->columns);
@@ -621,11 +626,11 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) {
while (grp && grp_y < y + h + listview->scrollpos) {
// render title
DdbListviewIter it = grp->head;
- listview->binding->ref (it);
int grpheight = grp->height;
if (grp_y >= y + h + listview->scrollpos) {
break;
}
+ listview->binding->ref (it);
if (grp_y + listview->grouptitle_height >= y + listview->scrollpos && grp_y < y + h + listview->scrollpos) {
ddb_listview_list_render_row_background (listview, NULL, idx & 1, 0, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height);
if (listview->binding->draw_group_title && listview->grouptitle_height > 0) {
@@ -858,7 +863,6 @@ ddb_listview_list_drag_data_received (GtkWidget *widget,
return;
}
int sel = ddb_listview_dragdrop_get_row_from_coord (ps, y);
- printf ("sel=%d\n", sel);
DdbListviewIter it = NULL;
if (sel == -1) {
if (ps->binding->count () != 0) {
@@ -892,7 +896,6 @@ ddb_listview_list_drag_data_received (GtkWidget *widget,
}
ps->binding->drag_n_drop (drop_before, d, length);
}
- printf ("gtk_drag_finish\n");
gtk_drag_finish (drag_context, TRUE, FALSE, time);
}
@@ -2673,7 +2676,6 @@ ddb_listview_build_groups (DdbListview *listview) {
listview->groups = grp;
memset (grp, 0, sizeof (DdbListviewGroup));
grp->head = it;
- listview->binding->ref (it);
grp->num_items = listview->binding->count ();
listview->grouptitle_height = 0;
grp->height = listview->grouptitle_height + grp->num_items * listview->rowheight;
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index c2a0745e..b1fa28af 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -207,9 +207,6 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) {
}
free (ptr);
- if (after) {
- deadbeef->pl_item_unref (after);
- }
g_idle_add (progress_hide_idle, NULL);
g_idle_add (set_dnd_cursor_idle, first);
}
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 8adbf7a9..98b20e85 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -24,8 +24,8 @@
#include <unistd.h>
#include "../../deadbeef.h"
-#define trace(...) { fprintf(stderr, __VA_ARGS__); }
-//#define trace(fmt,...)
+//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+#define trace(fmt,...)
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
@@ -1088,6 +1088,7 @@ cmp3_insert (DB_playItem_t *after, const char *fname) {
deadbeef->pl_set_item_duration (it, -1);
it->filetype = NULL;//filetypes[0];
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
buffer_t buffer;
@@ -1167,6 +1168,7 @@ cmp3_insert (DB_playItem_t *after, const char *fname) {
}
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/sid/csid.cpp b/plugins/sid/csid.cpp
index 9a21c1eb..09c1d3ec 100644
--- a/plugins/sid/csid.cpp
+++ b/plugins/sid/csid.cpp
@@ -545,6 +545,7 @@ csid_insert (DB_playItem_t *after, const char *fname) {
it->filetype = "SID";
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
}
}
delete tune;
diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c
index d44b8e16..09469206 100644
--- a/plugins/sndfile/sndfile.c
+++ b/plugins/sndfile/sndfile.c
@@ -240,6 +240,7 @@ sndfile_insert (DB_playItem_t *after, const char *fname) {
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 11a93dc2..4532eef9 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -374,6 +374,7 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) {
deadbeef->pl_set_item_duration (it, -1);
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
ov_callbacks ovcb = {
@@ -426,6 +427,7 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) {
}
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c
index 8d0291f2..e05870c9 100644
--- a/plugins/vtx/vtx.c
+++ b/plugins/vtx/vtx.c
@@ -271,6 +271,7 @@ vtx_insert (DB_playItem_t *after, const char *fname) {
ayemu_vtx_free (hdr);
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}
diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c
index ace9300a..931a9430 100644
--- a/plugins/wavpack/wavpack.c
+++ b/plugins/wavpack/wavpack.c
@@ -271,6 +271,7 @@ wv_insert (DB_playItem_t *after, const char *fname) {
deadbeef->pl_add_meta (it, "title", NULL);
after = deadbeef->pl_insert_item (after, it);
+ deadbeef->pl_item_unref (it);
return after;
}