diff options
author | Havoc Pennington <hp@redhat.com> | 2003-02-27 04:17:44 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-02-27 04:17:44 +0000 |
commit | 13f70ce711630d7f70c0b11fa57639fad95e4afd (patch) | |
tree | 80cbda896b78ff763f0c989576ac84e604ace026 /dbus/dbus-marshal.c | |
parent | b7bc5ba7a323c6a17a442310c40585b67edff5d4 (diff) |
2003-02-27 Havoc Pennington <hp@pobox.com>
* dbus/dbus-marshal.c (_dbus_demarshal_int32): rewrite to be much
more inlined, using dbus-string-private.h, speeds things up
substantially
* dbus/dbus-string.c (_dbus_string_free): apply align offset
when freeing the string
(_dbus_string_steal_data): fix for align offset
(undo_alignment): new function
Diffstat (limited to 'dbus/dbus-marshal.c')
-rw-r--r-- | dbus/dbus-marshal.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c index e29143ea..b199561b 100644 --- a/dbus/dbus-marshal.c +++ b/dbus/dbus-marshal.c @@ -23,6 +23,8 @@ #include "dbus-marshal.h" #include "dbus-internals.h" +#define DBUS_CAN_USE_DBUS_STRING_PRIVATE 1 +#include "dbus-string-private.h" #include <string.h> @@ -538,20 +540,21 @@ _dbus_demarshal_double (const DBusString *str, */ dbus_int32_t _dbus_demarshal_int32 (const DBusString *str, - int byte_order, - int pos, - int *new_pos) + int byte_order, + int pos, + int *new_pos) { - const char *buffer; - + const DBusRealString *real = (const DBusRealString*) str; + pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_int32_t)); - _dbus_string_get_const_data_len (str, &buffer, pos, sizeof (dbus_int32_t)); - if (new_pos) *new_pos = pos + sizeof (dbus_int32_t); - return _dbus_unpack_int32 (byte_order, buffer); + if (byte_order == DBUS_LITTLE_ENDIAN) + return DBUS_INT32_FROM_LE (*(dbus_int32_t*)(real->str + pos)); + else + return DBUS_INT32_FROM_BE (*(dbus_int32_t*)(real->str + pos)); } /** @@ -569,16 +572,17 @@ _dbus_demarshal_uint32 (const DBusString *str, int pos, int *new_pos) { - const char *buffer; - + const DBusRealString *real = (const DBusRealString*) str; + pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_uint32_t)); - _dbus_string_get_const_data_len (str, &buffer, pos, sizeof (dbus_uint32_t)); - if (new_pos) *new_pos = pos + sizeof (dbus_uint32_t); - return _dbus_unpack_uint32 (byte_order, buffer); + if (byte_order == DBUS_LITTLE_ENDIAN) + return DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)(real->str + pos)); + else + return DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)(real->str + pos)); } /** |