#define MIN_ARRAY_SIZE 128
-static gint
-g_nearest_pow (gint num)
+static gsize
+g_nearest_pow (gsize num)
{
- gint n = 1;
+ gsize n = 1;
- while (n < num)
+ while (n < num && n > 0)
n <<= 1;
return n;
TODO: This wastes a lot of memory at large buffer sizes.
Figure out a more rational allocation strategy. */
new_size = g_nearest_pow (mbuf->pos + count);
- /* Check for overflow again. We have only checked if
- pos + count > G_MAXSIZE, but it only catches the case of writing
- more than 4GiB total on a 32-bit system. There's still the problem
- of g_nearest_pow overflowing above 0x7fffffff, so we're
- effectively limited to 2GiB. */
- if (new_size < mbuf->len)
+ /* Check for overflow again. We have checked if
+ pos + count > G_MAXSIZE, but now check if g_nearest_pow () has
+ overflowed */
+ if (new_size == 0)
return FALSE;
new_size = MAX (new_size, MIN_ARRAY_SIZE);
{
/* NB: we do not treat 'b' as fixed-size here because GVariant and
* D-Bus disagree about the size.
- *
- * In addition 'd' is encoded differently by GVariant and DBus, so
- * we force (en|de)coding rather than direct use of fixed data.
- *
- * https://bugzilla.gnome.org/show_bug.cgi?id=732754
*/
switch (*g_variant_type_peek_string (type))
{
return 2;
case 'i': case 'u': case 'h':
return 4;
- case 'x': case 't':
+ case 'x': case 't': case 'd':
return 8;
default:
return 0;
else
use_value = g_variant_ref (value);
- ensure_output_padding (mbuf, fixed_size);
+ array_payload_begin_offset += ensure_output_padding (mbuf, fixed_size);
+
array_len = g_variant_get_size (use_value);
g_memory_buffer_write (mbuf, g_variant_get_data (use_value), array_len);
g_variant_unref (use_value);
#endif
return ret;
}
+
+void
+g_dbus_message_init_header_iter (GDBusMessage *message,
+ GHashTableIter *iter)
+{
+ g_hash_table_iter_init (iter, message->headers);
+}