summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2022-03-01 10:54:05 +0100
committerSimon McVittie <smcv@collabora.com>2022-04-21 13:55:38 +0100
commit21a6441f33bcf8cc7749af3d0d1dfc874e4a5c99 (patch)
tree3fcc29b027a42f859fb5c08754982ddb60c3324e /dbus
parentda36b47af1b27606190e0f9ad27aaa23eb187304 (diff)
downloaddbus-21a6441f33bcf8cc7749af3d0d1dfc874e4a5c99.tar.gz
_dbus_string_test(): Fix fatal build error caused by "-Wstrict-aliasing"
To fix this problem, the problematic code was replaced by a new function _dbus_string_get_allocated_size(), which uses the existing macro DBUS_CONST_STRING_PREAMBLE for these purposes. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-string.c14
-rw-r--r--dbus/dbus-string.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 529a099e..9c917cd9 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -466,6 +466,20 @@ open_gap (int len,
return TRUE;
}
+/**
+ * Returns the allocated size of the string
+ *
+ * @param str the string
+ * @returns the allocated size
+ */
+int
+_dbus_string_get_allocated_size (const DBusString *str)
+{
+ DBUS_CONST_STRING_PREAMBLE (str);
+
+ return real->allocated;
+}
+
#ifndef _dbus_string_get_data
/**
* Gets the raw character buffer from the string. The returned buffer
diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h
index ff81102c..b75da1aa 100644
--- a/dbus/dbus-string.h
+++ b/dbus/dbus-string.h
@@ -105,6 +105,8 @@ void _dbus_string_lock (DBusString *str);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_compact (DBusString *str,
int max_waste);
+DBUS_PRIVATE_EXPORT
+int _dbus_string_get_allocated_size (const DBusString *str);
#ifndef _dbus_string_get_data
DBUS_PRIVATE_EXPORT
char* _dbus_string_get_data (DBusString *str);