Skip to content

Commit

Permalink
cutils: add qemu_pstrcmp0()
Browse files Browse the repository at this point in the history
A char** variant of g_strcmp0().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
elmarco committed Oct 5, 2018
1 parent a95db58 commit 85e33a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/qemu/cutils.h
Expand Up @@ -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
5 changes: 5 additions & 0 deletions util/cutils.c
Expand Up @@ -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);
}

0 comments on commit 85e33a2

Please sign in to comment.