Commit cf49edba authored by Dafydd Harries's avatar Dafydd Harries

factor out attribute decoding from memory allocation

darcs-hash:20070111161553-c9803-b38789d8d3bc3e0b58fa14d63076f8e581bfb16a.gz
parent ef2a189e
...@@ -35,13 +35,10 @@ stun_attribute_free (StunAttribute *attr) ...@@ -35,13 +35,10 @@ stun_attribute_free (StunAttribute *attr)
g_slice_free (StunAttribute, attr); g_slice_free (StunAttribute, attr);
} }
StunAttribute * static void
stun_attribute_unpack (guint length, const gchar *s) _stun_attribute_unpack (StunAttribute *attr, guint length, const gchar *s)
{ {
StunAttribute *attr; attr->type = ntohs (*(guint16 *) s);
g_assert (length);
attr = stun_attribute_new (ntohs (*(guint16 *)s));
switch (attr->type) switch (attr->type)
{ {
...@@ -54,6 +51,16 @@ stun_attribute_unpack (guint length, const gchar *s) ...@@ -54,6 +51,16 @@ stun_attribute_unpack (guint length, const gchar *s)
default: default:
break; break;
} }
}
StunAttribute *
stun_attribute_unpack (guint length, const gchar *s)
{
StunAttribute *attr;
g_assert (length);
attr = stun_attribute_new (0);
_stun_attribute_unpack (attr, length, s);
return attr; return attr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment