[gstreamer-bugs] [Bug 347293] GstValueList comparison is flawed

GStreamer (bugzilla.gnome.org) bugzilla-daemon at bugzilla.gnome.org
Fri Jul 14 02:45:29 PDT 2006


Do not reply to this via email (we are currently unable to handle email
responses and they get discarded).  You can add comments to this bug at
http://bugzilla.gnome.org/show_bug.cgi?id=347293
 GStreamer | gstreamer (core) | Ver: HEAD CVS


Wim Taymans changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wim at fluendo.com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1




------- Comment #1 from Wim Taymans  2006-07-14 09:45 UTC -------
Something like this?

/* Do an unordered compare of the contents of a list */
static int
gst_value_compare_list (const GValue * value1, const GValue * value2)
{
  guint i, j;
  GArray *array1 = value1->data[0].v_pointer;
  GArray *array2 = value2->data[0].v_pointer;
  GValue *v1;
  GValue *v2;
  gint len, to_remove;
  guint8 *removed;

  /* get length and do initial length check. */
  len = array1->len;
  if (len != array2->len)
    return GST_VALUE_UNORDERED;

  /* place to mark removed value indices of array2 */
  removed = g_newa (guint8, len);
  memset (removed, 0, len);
  to_remove = len;

  /* loop over array1, all items should be in array2. When we find an
   * item in array2, remove it from array2 by marking it as removed */
  for (i = 0; i < len; i++) {
    v1 = &g_array_index (array1, GValue, i);
    for (j = 0; j < len; j++) {
      /* item is removed, we can skip it */
      if (removed[j])
        continue;
      v2 = &g_array_index (array2, GValue, j);
      if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL) {
        /* mark item as removed now that we found it in array2 and
         * decrement the number of remaining items in array2. */
        removed[j] = 1;
        to_remove--;
        break;
      }
    }
    /* item in array1 and not in array2, UNORDERED */
    if (j == len)
      return GST_VALUE_UNORDERED;
  }
  /* if not all items were removed, array2 contained something not in array1 */
  if (to_remove != 0)
    return GST_VALUE_UNORDERED;

  /* arrays are equal */
  return GST_VALUE_EQUAL;
}


-- 
Configure bugmail: http://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.




More information about the Gstreamer-bugs mailing list