typefind: use gslice for typefine data

Also use our free function in the failure case.
This commit is contained in:
Stefan Sauer 2014-10-17 12:10:44 +02:00
parent d0aa9f9a34
commit 7c247ab166

View file

@ -5357,12 +5357,12 @@ sw_data_destroy (GstTypeFindData * sw_data)
{ {
if (G_LIKELY (sw_data->caps != NULL)) if (G_LIKELY (sw_data->caps != NULL))
gst_caps_unref (sw_data->caps); gst_caps_unref (sw_data->caps);
g_free (sw_data); g_slice_free (GstTypeFindData, sw_data);
} }
#define TYPE_FIND_REGISTER_START_WITH(plugin,name,rank,ext,_data,_size,_probability)\ #define TYPE_FIND_REGISTER_START_WITH(plugin,name,rank,ext,_data,_size,_probability)\
G_BEGIN_DECLS{ \ G_BEGIN_DECLS{ \
GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \ GstTypeFindData *sw_data = g_slice_new (GstTypeFindData); \
sw_data->data = (const guint8 *)_data; \ sw_data->data = (const guint8 *)_data; \
sw_data->size = _size; \ sw_data->size = _size; \
sw_data->probability = _probability; \ sw_data->probability = _probability; \
@ -5370,8 +5370,7 @@ G_BEGIN_DECLS{ \
if (!gst_type_find_register (plugin, name, rank, start_with_type_find,\ if (!gst_type_find_register (plugin, name, rank, start_with_type_find,\
ext, sw_data->caps, sw_data, \ ext, sw_data->caps, sw_data, \
(GDestroyNotify) (sw_data_destroy))) { \ (GDestroyNotify) (sw_data_destroy))) { \
gst_caps_unref (sw_data->caps); \ sw_data_destroy (sw_data); \
g_free (sw_data); \
} \ } \
}G_END_DECLS }G_END_DECLS
@ -5392,7 +5391,7 @@ riff_type_find (GstTypeFind * tf, gpointer private)
#define TYPE_FIND_REGISTER_RIFF(plugin,name,rank,ext,_data) \ #define TYPE_FIND_REGISTER_RIFF(plugin,name,rank,ext,_data) \
G_BEGIN_DECLS{ \ G_BEGIN_DECLS{ \
GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \ GstTypeFindData *sw_data = g_slice_new (GstTypeFindData); \
sw_data->data = (gpointer)_data; \ sw_data->data = (gpointer)_data; \
sw_data->size = 4; \ sw_data->size = 4; \
sw_data->probability = GST_TYPE_FIND_MAXIMUM; \ sw_data->probability = GST_TYPE_FIND_MAXIMUM; \
@ -5400,8 +5399,7 @@ G_BEGIN_DECLS{ \
if (!gst_type_find_register (plugin, name, rank, riff_type_find, \ if (!gst_type_find_register (plugin, name, rank, riff_type_find, \
ext, sw_data->caps, sw_data, \ ext, sw_data->caps, sw_data, \
(GDestroyNotify) (sw_data_destroy))) { \ (GDestroyNotify) (sw_data_destroy))) { \
gst_caps_unref (sw_data->caps); \ sw_data_destroy (sw_data); \
g_free (sw_data); \
} \ } \
}G_END_DECLS }G_END_DECLS