memory: make guint8 * for easy usage
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 20 Jan 2012 15:10:26 +0000 (16:10 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 25 Jan 2012 10:54:23 +0000 (11:54 +0100)
gst/gstmemory.c
gst/gstmemory.h
tests/check/gst/gstbuffer.c
tests/check/gst/gstmemory.c

index b72b6fc..83ef9fe 100644 (file)
@@ -283,7 +283,7 @@ _fallback_copy (GstMemory * mem, gssize offset, gssize size)
     return NULL;
   }
 
-  memcpy (dinfo.data, (guint8 *) sinfo.data + offset, size);
+  memcpy (dinfo.data, sinfo.data + offset, size);
   gst_memory_unmap (copy, &dinfo);
   gst_memory_unmap (mem, &sinfo);
 
@@ -584,7 +584,7 @@ gst_memory_map (GstMemory * mem, GstMapInfo * info, GstMapFlags flags)
   info->memory = mem;
   info->size = mem->size;
   info->maxsize = mem->maxsize - mem->offset;
-  info->data = (guint8 *) info->data + mem->offset;
+  info->data = info->data + mem->offset;
 
   return TRUE;
 
index 6231f74..4300641 100644 (file)
@@ -110,7 +110,7 @@ typedef enum {
  */
 typedef struct {
   GstMemory *memory;
-  gpointer data;
+  guint8 *data;
   gsize size;
   gsize maxsize;
 } GstMapInfo;
index fcbca88..0054a20 100644 (file)
@@ -58,7 +58,7 @@ GST_START_TEST (test_subbuffer)
 
   fail_unless (gst_buffer_map (sub, &sinfo, GST_MAP_READ));
   fail_unless (sinfo.size == 2, "subbuffer has wrong size");
-  fail_unless (memcmp ((guint8 *) info.data + 1, sinfo.data, 2) == 0,
+  fail_unless (memcmp (info.data + 1, sinfo.data, 2) == 0,
       "subbuffer contains the wrong data");
   ASSERT_BUFFER_REFCOUNT (sub, "subbuffer", 1);
   fail_unless (GST_BUFFER_TIMESTAMP (sub) == -1,
@@ -75,7 +75,7 @@ GST_START_TEST (test_subbuffer)
   fail_if (sub == NULL, "copy_region of buffer returned NULL");
   fail_unless (gst_buffer_map (sub, &sinfo, GST_MAP_READ));
   fail_unless (sinfo.size == 0, "subbuffer has wrong size");
-  fail_unless (memcmp ((guint8 *) info.data + 1, sinfo.data, 0) == 0,
+  fail_unless (memcmp (info.data + 1, sinfo.data, 0) == 0,
       "subbuffer contains the wrong data");
   ASSERT_BUFFER_REFCOUNT (sub, "subbuffer", 1);
   gst_buffer_unmap (sub, &sinfo);
@@ -261,7 +261,7 @@ GST_START_TEST (test_make_writable)
   buf = create_read_only_buffer ();
 
   fail_unless (gst_buffer_map (buf, &info, GST_MAP_WRITE));
-  ((guint8 *) info.data)[4] = 'a';
+  info.data[4] = 'a';
   gst_buffer_unmap (buf, &info);
   gst_buffer_unref (buf);
 
@@ -295,7 +295,7 @@ GST_START_TEST (test_subbuffer_make_writable)
 
   fail_unless (gst_buffer_map (sub_buf, &info, GST_MAP_WRITE));
   fail_if (info.data == NULL);
-  ((guint8 *) info.data)[4] = 'a';
+  info.data[4] = 'a';
   gst_buffer_unmap (sub_buf, &info);
   gst_buffer_unref (sub_buf);
   gst_buffer_unref (buf);
@@ -413,7 +413,7 @@ GST_START_TEST (test_try_new_and_alloc)
   fail_unless (gst_buffer_map (buf, &info, GST_MAP_WRITE));
   fail_unless (info.data != NULL);
   fail_unless (info.size == (640 * 480 * 4));
-  ((guint8 *) info.data)[640 * 479 * 4 + 479] = 0xff;
+  info.data[640 * 479 * 4 + 479] = 0xff;
   gst_buffer_unmap (buf, &info);
 
   gst_buffer_unref (buf);
index 6fbb481..1c6bf8a 100644 (file)
@@ -53,7 +53,7 @@ GST_START_TEST (test_submemory)
 
   fail_unless (gst_memory_map (sub, &sinfo, GST_MAP_READ));
   fail_unless (sinfo.size == 2, "submemory has wrong size");
-  fail_unless (memcmp (((guint8 *) info.data) + 1, sinfo.data, 2) == 0,
+  fail_unless (memcmp (info.data + 1, sinfo.data, 2) == 0,
       "submemory contains the wrong data");
   ASSERT_MEMORY_REFCOUNT (sub, "submemory", 1);
   gst_memory_unmap (sub, &sinfo);
@@ -64,7 +64,7 @@ GST_START_TEST (test_submemory)
   fail_if (sub == NULL, "share memory returned NULL");
   fail_unless (gst_memory_map (sub, &sinfo, GST_MAP_READ));
   fail_unless (sinfo.size == 0, "submemory has wrong size");
-  fail_unless (memcmp (((guint8 *) info.data) + 1, sinfo.data, 0) == 0,
+  fail_unless (memcmp (info.data + 1, sinfo.data, 0) == 0,
       "submemory contains the wrong data");
   ASSERT_MEMORY_REFCOUNT (sub, "submemory", 1);
   gst_memory_unmap (sub, &sinfo);
@@ -154,7 +154,7 @@ GST_START_TEST (test_writable)
   fail_unless (gst_memory_is_writable (mem2));
 
   fail_unless (gst_memory_map (mem2, &info, GST_MAP_WRITE));
-  ((guint8 *) info.data)[4] = 'a';
+  info.data[4] = 'a';
   gst_memory_unmap (mem2, &info);
 
   gst_memory_ref (mem2);
@@ -162,7 +162,7 @@ GST_START_TEST (test_writable)
   gst_memory_unref (mem2);
 
   fail_unless (gst_memory_map (mem2, &info, GST_MAP_WRITE));
-  ((guint8 *) info.data)[4] = 'a';
+  info.data[4] = 'a';
   gst_memory_unmap (mem2, &info);
   gst_memory_unref (mem2);
 
@@ -252,7 +252,7 @@ GST_START_TEST (test_try_new_and_alloc)
   fail_unless (gst_memory_map (mem, &info, GST_MAP_WRITE));
   fail_unless (info.data != NULL);
   fail_unless (info.size == (640 * 480 * 4));
-  ((guint8 *) info.data)[640 * 479 * 4 + 479] = 0xff;
+  info.data[640 * 479 * 4 + 479] = 0xff;
   gst_memory_unmap (mem, &info);
 
   gst_memory_unref (mem);