diff options
-rw-r--r-- | include/qemu/cutils.h | 12 | ||||
-rw-r--r-- | util/cutils.c | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 47aaa3b0b9..7071bfe2d4 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -169,4 +169,16 @@ bool test_buffer_is_zero_next_accel(void); int uleb128_encode_small(uint8_t *out, uint32_t n); int uleb128_decode_small(const uint8_t *in, uint32_t *n); +/** + * qemu_pstrcmp0: + * @str1: a non-NULL pointer to a C string (*str1 can be NULL) + * @str2: a non-NULL pointer to a C string (*str2 can be NULL) + * + * Compares *str1 and *str2 with g_strcmp0(). + * + * Returns: an integer less than, equal to, or greater than zero, if + * *str1 is <, == or > than *str2. + */ +int qemu_pstrcmp0(const char **str1, const char **str2); + #endif diff --git a/util/cutils.c b/util/cutils.c index 9205e09031..698bd315bd 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -769,3 +769,8 @@ char *size_to_str(uint64_t val) return g_strdup_printf("%0.3g %sB", (double)val / div, suffixes[i]); } + +int qemu_pstrcmp0(const char **str1, const char **str2) +{ + return g_strcmp0(*str1, *str2); +} |