diff --git a/libfwupdplugin/fu-common.c b/libfwupdplugin/fu-common.c index 7443989f2..3f5e0ad60 100644 --- a/libfwupdplugin/fu-common.c +++ b/libfwupdplugin/fu-common.c @@ -1942,6 +1942,27 @@ fu_common_bytes_compare(GBytes *bytes1, GBytes *bytes2, GError **error) return fu_common_bytes_compare_raw(buf1, bufsz1, buf2, bufsz2, error); } +/** + * fu_byte_array_compare: + * @buf1: a data blob + * @buf2: another #GByteArray + * @error: (nullable): optional return location for an error + * + * Compares two buffers for equality. + * + * Returns: %TRUE if @buf1 and @buf2 are identical + * + * Since: 1.8.0 + **/ +gboolean +fu_byte_array_compare(GByteArray *buf1, GByteArray *buf2, GError **error) +{ + g_return_val_if_fail(buf1 != NULL, FALSE); + g_return_val_if_fail(buf2 != NULL, FALSE); + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + return fu_common_bytes_compare_raw(buf1->data, buf1->len, buf2->data, buf2->len, error); +} + /** * fu_common_bytes_pad: * @bytes: data blob diff --git a/libfwupdplugin/fu-common.h b/libfwupdplugin/fu-common.h index 0b39a0b9b..af69a1933 100644 --- a/libfwupdplugin/fu-common.h +++ b/libfwupdplugin/fu-common.h @@ -359,6 +359,8 @@ void fu_byte_array_append_uint64(GByteArray *array, guint64 data, FuEndianType endian); void fu_byte_array_append_bytes(GByteArray *array, GBytes *bytes); +gboolean +fu_byte_array_compare(GByteArray *buf1, GByteArray *buf2, GError **error); void fu_common_write_uint16(guint8 *buf, guint16 val_native, FuEndianType endian); diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index 4608d1f40..f39ebb3c8 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -1021,6 +1021,7 @@ LIBFWUPDPLUGIN_1.7.7 { LIBFWUPDPLUGIN_1.8.0 { global: fu_backend_invalidate; + fu_byte_array_compare; fu_cfi_device_chip_select; fu_cfi_device_chip_select_locker_new; fu_common_reverse_uint8;