[gst-cvs] gstreamer: bytereader: const-ify byte reader argument in peek/scan API

Tim Müller tpm at kemper.freedesktop.org
Fri Oct 22 04:15:46 PDT 2010


Module: gstreamer
Branch: master
Commit: 07755fd5ee0cb2237666c027a5efd21a15713556
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=07755fd5ee0cb2237666c027a5efd21a15713556

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Mon Oct 18 17:42:27 2010 +0100

bytereader: const-ify byte reader argument in peek/scan API

Because we can.

---

 libs/gst/base/gstbytereader.c |   11 ++++---
 libs/gst/base/gstbytereader.h |   66 ++++++++++++++++++++--------------------
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/libs/gst/base/gstbytereader.c b/libs/gst/base/gstbytereader.c
index 77cf755..d8796aa 100644
--- a/libs/gst/base/gstbytereader.c
+++ b/libs/gst/base/gstbytereader.c
@@ -707,7 +707,7 @@ gst_byte_reader_get_##name (GstByteReader * reader, type * val) \
 } \
 \
 gboolean \
-gst_byte_reader_peek_##name (GstByteReader * reader, type * val) \
+gst_byte_reader_peek_##name (const GstByteReader * reader, type * val) \
 { \
   return _gst_byte_reader_peek_##name##_inline (reader, val); \
 }
@@ -886,7 +886,7 @@ gst_byte_reader_get_data (GstByteReader * reader, guint size,
  * Since: 0.10.22
  */
 gboolean
-gst_byte_reader_peek_data (GstByteReader * reader, guint size,
+gst_byte_reader_peek_data (const GstByteReader * reader, guint size,
     const guint8 ** val)
 {
   return _gst_byte_reader_peek_data_inline (reader, size, val);
@@ -957,7 +957,7 @@ gst_byte_reader_dup_data (GstByteReader * reader, guint size, guint8 ** val)
  * Since: 0.10.24
  */
 guint
-gst_byte_reader_masked_scan_uint32 (GstByteReader * reader, guint32 mask,
+gst_byte_reader_masked_scan_uint32 (const GstByteReader * reader, guint32 mask,
     guint32 pattern, guint offset, guint size)
 {
   const guint8 *data;
@@ -995,7 +995,7 @@ gst_byte_reader_masked_scan_uint32 (GstByteReader * reader, guint32 mask,
 
 #define GST_BYTE_READER_SCAN_STRING(bits) \
 static guint \
-gst_byte_reader_scan_string_utf##bits (GstByteReader * reader) \
+gst_byte_reader_scan_string_utf##bits (const GstByteReader * reader) \
 { \
   guint len, off, max_len; \
   \
@@ -1141,7 +1141,8 @@ GST_BYTE_READER_SKIP_STRING (32);
  * Since: 0.10.24
  */
 gboolean
-gst_byte_reader_peek_string_utf8 (GstByteReader * reader, const gchar ** str)
+gst_byte_reader_peek_string_utf8 (const GstByteReader * reader,
+    const gchar ** str)
 {
   g_return_val_if_fail (reader != NULL, FALSE);
   g_return_val_if_fail (str != NULL, FALSE);
diff --git a/libs/gst/base/gstbytereader.h b/libs/gst/base/gstbytereader.h
index 377126a..f25c3b5 100644
--- a/libs/gst/base/gstbytereader.h
+++ b/libs/gst/base/gstbytereader.h
@@ -78,38 +78,38 @@ gboolean gst_byte_reader_get_int64_le (GstByteReader *reader, gint64 *val);
 gboolean gst_byte_reader_get_uint64_be (GstByteReader *reader, guint64 *val);
 gboolean gst_byte_reader_get_int64_be (GstByteReader *reader, gint64 *val);
 
-gboolean gst_byte_reader_peek_uint8 (GstByteReader *reader, guint8 *val);
-gboolean gst_byte_reader_peek_int8 (GstByteReader *reader, gint8 *val);
-gboolean gst_byte_reader_peek_uint16_le (GstByteReader *reader, guint16 *val);
-gboolean gst_byte_reader_peek_int16_le (GstByteReader *reader, gint16 *val);
-gboolean gst_byte_reader_peek_uint16_be (GstByteReader *reader, guint16 *val);
-gboolean gst_byte_reader_peek_int16_be (GstByteReader *reader, gint16 *val);
-gboolean gst_byte_reader_peek_uint24_le (GstByteReader *reader, guint32 *val);
-gboolean gst_byte_reader_peek_int24_le (GstByteReader *reader, gint32 *val);
-gboolean gst_byte_reader_peek_uint24_be (GstByteReader *reader, guint32 *val);
-gboolean gst_byte_reader_peek_int24_be (GstByteReader *reader, gint32 *val);
-gboolean gst_byte_reader_peek_uint32_le (GstByteReader *reader, guint32 *val);
-gboolean gst_byte_reader_peek_int32_le (GstByteReader *reader, gint32 *val);
-gboolean gst_byte_reader_peek_uint32_be (GstByteReader *reader, guint32 *val);
-gboolean gst_byte_reader_peek_int32_be (GstByteReader *reader, gint32 *val);
-gboolean gst_byte_reader_peek_uint64_le (GstByteReader *reader, guint64 *val);
-gboolean gst_byte_reader_peek_int64_le (GstByteReader *reader, gint64 *val);
-gboolean gst_byte_reader_peek_uint64_be (GstByteReader *reader, guint64 *val);
-gboolean gst_byte_reader_peek_int64_be (GstByteReader *reader, gint64 *val);
+gboolean gst_byte_reader_peek_uint8 (const GstByteReader *reader, guint8 *val);
+gboolean gst_byte_reader_peek_int8 (const GstByteReader *reader, gint8 *val);
+gboolean gst_byte_reader_peek_uint16_le (const GstByteReader *reader, guint16 *val);
+gboolean gst_byte_reader_peek_int16_le (const GstByteReader *reader, gint16 *val);
+gboolean gst_byte_reader_peek_uint16_be (const GstByteReader *reader, guint16 *val);
+gboolean gst_byte_reader_peek_int16_be (const GstByteReader *reader, gint16 *val);
+gboolean gst_byte_reader_peek_uint24_le (const GstByteReader *reader, guint32 *val);
+gboolean gst_byte_reader_peek_int24_le (const GstByteReader *reader, gint32 *val);
+gboolean gst_byte_reader_peek_uint24_be (const GstByteReader *reader, guint32 *val);
+gboolean gst_byte_reader_peek_int24_be (const GstByteReader *reader, gint32 *val);
+gboolean gst_byte_reader_peek_uint32_le (const GstByteReader *reader, guint32 *val);
+gboolean gst_byte_reader_peek_int32_le (const GstByteReader *reader, gint32 *val);
+gboolean gst_byte_reader_peek_uint32_be (const GstByteReader *reader, guint32 *val);
+gboolean gst_byte_reader_peek_int32_be (const GstByteReader *reader, gint32 *val);
+gboolean gst_byte_reader_peek_uint64_le (const GstByteReader *reader, guint64 *val);
+gboolean gst_byte_reader_peek_int64_le (const GstByteReader *reader, gint64 *val);
+gboolean gst_byte_reader_peek_uint64_be (const GstByteReader *reader, guint64 *val);
+gboolean gst_byte_reader_peek_int64_be (const GstByteReader *reader, gint64 *val);
 
 gboolean gst_byte_reader_get_float32_le (GstByteReader *reader, gfloat *val);
 gboolean gst_byte_reader_get_float32_be (GstByteReader *reader, gfloat *val);
 gboolean gst_byte_reader_get_float64_le (GstByteReader *reader, gdouble *val);
 gboolean gst_byte_reader_get_float64_be (GstByteReader *reader, gdouble *val);
 
-gboolean gst_byte_reader_peek_float32_le (GstByteReader *reader, gfloat *val);
-gboolean gst_byte_reader_peek_float32_be (GstByteReader *reader, gfloat *val);
-gboolean gst_byte_reader_peek_float64_le (GstByteReader *reader, gdouble *val);
-gboolean gst_byte_reader_peek_float64_be (GstByteReader *reader, gdouble *val);
+gboolean gst_byte_reader_peek_float32_le (const GstByteReader *reader, gfloat *val);
+gboolean gst_byte_reader_peek_float32_be (const GstByteReader *reader, gfloat *val);
+gboolean gst_byte_reader_peek_float64_le (const GstByteReader *reader, gdouble *val);
+gboolean gst_byte_reader_peek_float64_be (const GstByteReader *reader, gdouble *val);
 
 gboolean gst_byte_reader_dup_data  (GstByteReader * reader, guint size, guint8       ** val);
 gboolean gst_byte_reader_get_data  (GstByteReader * reader, guint size, const guint8 ** val);
-gboolean gst_byte_reader_peek_data (GstByteReader * reader, guint size, const guint8 ** val);
+gboolean gst_byte_reader_peek_data (const GstByteReader * reader, guint size, const guint8 ** val);
 
 #define gst_byte_reader_dup_string(reader,str) \
     gst_byte_reader_dup_string_utf8(reader,str)
@@ -132,13 +132,13 @@ gboolean gst_byte_reader_skip_string_utf32 (GstByteReader * reader);
     gst_byte_reader_peek_string_utf8(reader,str)
 
 gboolean gst_byte_reader_get_string_utf8   (GstByteReader * reader, const gchar ** str);
-gboolean gst_byte_reader_peek_string_utf8  (GstByteReader * reader, const gchar ** str);
+gboolean gst_byte_reader_peek_string_utf8  (const GstByteReader * reader, const gchar ** str);
 
-guint    gst_byte_reader_masked_scan_uint32 (GstByteReader * reader,
-                                             guint32         mask,
-                                             guint32         pattern,
-                                             guint           offset,
-                                             guint           size);
+guint    gst_byte_reader_masked_scan_uint32 (const GstByteReader * reader,
+                                             guint32               mask,
+                                             guint32               pattern,
+                                             guint                 offset,
+                                             guint                 size);
 
 /**
  * GST_BYTE_READER_INIT:
@@ -178,7 +178,7 @@ gst_byte_reader_skip_unchecked (GstByteReader * reader, guint nbytes)
 #define __GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(bits,type,lower,upper,adj) \
 \
 static inline type \
-gst_byte_reader_peek_##lower##_unchecked (GstByteReader * reader) \
+gst_byte_reader_peek_##lower##_unchecked (const GstByteReader * reader) \
 { \
   type val = (type) GST_READ_##upper (reader->data + reader->byte); \
   adj \
@@ -228,7 +228,7 @@ __GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gdouble,float64_be,DOUBLE_BE,/* */)
 #undef __GET_PEEK_BITS_UNCHECKED
 
 static inline const guint8 *
-gst_byte_reader_peek_data_unchecked (GstByteReader * reader)
+gst_byte_reader_peek_data_unchecked (const GstByteReader * reader)
 {
   return (const guint8 *) (reader->data + reader->byte);
 }
@@ -289,7 +289,7 @@ _gst_byte_reader_get_size_inline (const GstByteReader * reader)
 #define __GST_BYTE_READER_GET_PEEK_BITS_INLINE(bits,type,name) \
 \
 static inline gboolean \
-_gst_byte_reader_peek_##name##_inline (GstByteReader * reader, type * val) \
+_gst_byte_reader_peek_##name##_inline (const GstByteReader * reader, type * val) \
 { \
   g_return_val_if_fail (reader != NULL, FALSE); \
   g_return_val_if_fail (val != NULL, FALSE); \
@@ -476,7 +476,7 @@ _gst_byte_reader_get_data_inline (GstByteReader * reader, guint size, const guin
 }
 
 static inline gboolean
-_gst_byte_reader_peek_data_inline (GstByteReader * reader, guint size, const guint8 ** val)
+_gst_byte_reader_peek_data_inline (const GstByteReader * reader, guint size, const guint8 ** val)
 {
   g_return_val_if_fail (reader != NULL, FALSE);
   g_return_val_if_fail (val != NULL, FALSE);





More information about the Gstreamer-commits mailing list