summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-01-31 11:42:16 +0000
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-02-24 16:03:24 -0500
commita2e131247d4147cbe434b79d3a7732b1e05dad9c (patch)
tree09d0ff47eed81c6aa2e7f2e100c23ceb444504cf
parentb93ecef209e114d10b4df5133a6871bd5d646c77 (diff)
agent: Add nice_input_message_iter_compare()
Use it instead of memcmp() to avoid comparing padding bytes.
-rw-r--r--agent/agent-priv.h3
-rw-r--r--agent/agent.c23
2 files changed, 24 insertions, 2 deletions
diff --git a/agent/agent-priv.h b/agent/agent-priv.h
index bfd7d90..a49d9a5 100644
--- a/agent/agent-priv.h
+++ b/agent/agent-priv.h
@@ -82,6 +82,9 @@ nice_input_message_iter_is_at_end (NiceInputMessageIter *iter,
NiceInputMessage *messages, guint n_messages);
guint
nice_input_message_iter_get_n_valid_messages (NiceInputMessageIter *iter);
+gboolean
+nice_input_message_iter_compare (const NiceInputMessageIter *a,
+ const NiceInputMessageIter *b);
#include "socket.h"
diff --git a/agent/agent.c b/agent/agent.c
index 96772cb..f5114b0 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -2970,6 +2970,25 @@ nice_input_message_iter_get_n_valid_messages (NiceInputMessageIter *iter)
return iter->message + 1;
}
+/**
+ * nice_input_message_iter_compare:
+ * @a: a #NiceInputMessageIter
+ * @b: another #NiceInputMessageIter
+ *
+ * Compare two #NiceInputMessageIters for equality, returning %TRUE if they
+ * point to the same place in the receive message array.
+ *
+ * Returns: %TRUE if the iters match, %FALSE otherwise
+ *
+ * Since: 0.1.5
+ */
+gboolean
+nice_input_message_iter_compare (const NiceInputMessageIter *a,
+ const NiceInputMessageIter *b)
+{
+ return (a->message == b->message && a->buffer == b->buffer && a->offset == b->offset);
+}
+
/* Will fill up @messages from the first free byte onwards (as determined using
* @iter). This may be used in reliable or non-reliable mode; in non-reliable
* mode it will always increment the message index after each buffer is
@@ -3182,8 +3201,8 @@ nice_agent_recv_messages_blocking_or_nonblocking (NiceAgent *agent,
component->recv_messages, component->n_recv_messages);
error_reported = (child_error != NULL);
all_sockets_would_block = (!blocking &&
- memcmp (&prev_recv_messages_iter, &component->recv_messages_iter,
- sizeof (NiceInputMessageIter)) == 0);
+ nice_input_message_iter_compare (&prev_recv_messages_iter,
+ &component->recv_messages_iter));
}
n_valid_messages =