GVariant: create child instance from its own data

also: white-space fix in the serialiser
This commit is contained in:
Ryan Lortie 2010-02-15 19:11:58 -05:00
parent 7fb9d536c0
commit b899bfc741
2 changed files with 6 additions and 3 deletions

View File

@ -800,17 +800,21 @@ g_variant_get_child_value (GVariant *value,
};
GVariantSerialised s_child;
/* get the serialiser to extract the serialised data for the child
* from the serialised data for the container
*/
s_child = g_variant_serialised_get_child (serialised, index_);
/* create a new serialised instance out of it */
child = g_slice_new (GVariant);
child->type_info = s_child.type_info;
child->state = (value->state & STATE_TRUSTED) |
STATE_SERIALISED;
child->size = serialised.size;
child->size = s_child.size;
child->ref_count = 1;
child->contents.serialised.buffer =
g_buffer_ref (value->contents.serialised.buffer);
child->contents.serialised.data = serialised.data;
child->contents.serialised.data = s_child.data;
}
else
child = g_variant_ref (value->contents.tree.children[index_]);

View File

@ -1114,7 +1114,6 @@ gvs_variant_get_child (GVariantSerialised value,
/* NOTE: not O(1) and impossible for it to be... */
if (value.size)
{
/* find '\0' character */
for (child.size = value.size - 1; child.size; child.size--)
if (value.data[child.size] == '\0')