Added gst_data_needs_copy_on_write()

Original commit message from CVS:
Added gst_data_needs_copy_on_write()
This commit is contained in:
David Schleef 2002-11-19 02:29:18 +00:00
parent edd2819c89
commit f42d7e6ac8
2 changed files with 21 additions and 0 deletions

View file

@ -92,6 +92,26 @@ gst_data_copy (const GstData *data)
return NULL;
}
/**
* gst_data_needs_copy_on_write:
* @data: a #GstData to copy
*
* Returns: TRUE if the given #GstData is potentially shared and needs to
* be copied before it can be modified safely.
*/
gboolean
gst_data_needs_copy_on_write (GstData *data)
{
gint refcount;
GST_ATOMIC_INT_READ (&data->refcount, &refcount);
if (refcount == 1 && !GST_DATA_FLAG_IS_SET (data, GST_DATA_READONLY))
return FALSE;
return TRUE;
}
/**
* gst_data_copy_on_write:
* @data: a #GstData to copy

View file

@ -87,6 +87,7 @@ void gst_data_copy_into (const GstData *data, GstData *target);
/* basic operations on data */
GstData* gst_data_copy (const GstData *data);
gboolean gst_data_needs_copy_on_write (GstData *data);
GstData* gst_data_copy_on_write (GstData *data);
void gst_data_free (GstData *data);