mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: remove VIR_STRDUP and VIR_STRNDUP
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ca4c90b435
commit
610963cd04
@ -3114,7 +3114,6 @@ virSkipSpaces;
|
|||||||
virSkipSpacesAndBackslash;
|
virSkipSpacesAndBackslash;
|
||||||
virSkipSpacesBackwards;
|
virSkipSpacesBackwards;
|
||||||
virStrcpy;
|
virStrcpy;
|
||||||
virStrdup;
|
|
||||||
virStringBufferIsPrintable;
|
virStringBufferIsPrintable;
|
||||||
virStringFilterChars;
|
virStringFilterChars;
|
||||||
virStringHasCaseSuffix;
|
virStringHasCaseSuffix;
|
||||||
@ -3149,7 +3148,6 @@ virStringStripSuffix;
|
|||||||
virStringToUpper;
|
virStringToUpper;
|
||||||
virStringTrimOptionalNewline;
|
virStringTrimOptionalNewline;
|
||||||
virStrncpy;
|
virStrncpy;
|
||||||
virStrndup;
|
|
||||||
virStrToDouble;
|
virStrToDouble;
|
||||||
virStrToLong_i;
|
virStrToLong_i;
|
||||||
virStrToLong_l;
|
virStrToLong_l;
|
||||||
|
@ -886,55 +886,6 @@ virStringIsEmpty(const char *str)
|
|||||||
return str[0] == '\0';
|
return str[0] == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* virStrdup:
|
|
||||||
* @dest: where to store duplicated string
|
|
||||||
* @src: the source string to duplicate
|
|
||||||
*
|
|
||||||
* Wrapper over strdup, which aborts on OOM error.
|
|
||||||
*
|
|
||||||
* Returns: 0 for NULL src, 1 on successful copy, aborts on OOM
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
virStrdup(char **dest,
|
|
||||||
const char *src)
|
|
||||||
{
|
|
||||||
*dest = NULL;
|
|
||||||
if (!src)
|
|
||||||
return 0;
|
|
||||||
*dest = g_strdup(src);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virStrndup:
|
|
||||||
* @dest: where to store duplicated string
|
|
||||||
* @src: the source string to duplicate
|
|
||||||
* @n: how many bytes to copy
|
|
||||||
*
|
|
||||||
* Wrapper over strndup, which aborts on OOM error.
|
|
||||||
*
|
|
||||||
* In case @n is smaller than zero, the whole @src string is
|
|
||||||
* copied.
|
|
||||||
*
|
|
||||||
* Returns: 0 for NULL src, 1 on successful copy, aborts on OOM
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
virStrndup(char **dest,
|
|
||||||
const char *src,
|
|
||||||
ssize_t n)
|
|
||||||
{
|
|
||||||
*dest = NULL;
|
|
||||||
if (!src)
|
|
||||||
return 0;
|
|
||||||
if (n < 0)
|
|
||||||
n = strlen(src);
|
|
||||||
*dest = g_strndup(src, n);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
size_t virStringListLength(const char * const *strings)
|
size_t virStringListLength(const char * const *strings)
|
||||||
{
|
{
|
||||||
|
@ -134,75 +134,6 @@ int virStrdup(char **dest, const char *src)
|
|||||||
int virStrndup(char **dest, const char *src, ssize_t n)
|
int virStrndup(char **dest, const char *src, ssize_t n)
|
||||||
G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
|
G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
/**
|
|
||||||
* VIR_STRDUP:
|
|
||||||
* @dst: variable to hold result (char*, not char**)
|
|
||||||
* @src: string to duplicate
|
|
||||||
*
|
|
||||||
* DEPRECATED: use g_strdup instead
|
|
||||||
*
|
|
||||||
* Duplicate @src string and store it into @dst.
|
|
||||||
*
|
|
||||||
* This macro is safe to use on arguments with side effects.
|
|
||||||
*
|
|
||||||
* Returns 0 if @src was NULL, 1 if @src was copied, aborts on OOM
|
|
||||||
*/
|
|
||||||
#define VIR_STRDUP(dst, src) virStrdup(&(dst), src)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* VIR_STRDUP_QUIET:
|
|
||||||
* @dst: variable to hold result (char*, not char**)
|
|
||||||
* @src: string to duplicate
|
|
||||||
*
|
|
||||||
* DEPRECATED: use g_strdup instead
|
|
||||||
*
|
|
||||||
* Duplicate @src string and store it into @dst.
|
|
||||||
*
|
|
||||||
* This macro is safe to use on arguments with side effects.
|
|
||||||
*
|
|
||||||
* Returns 0 if @src was NULL, 1 if @src was copied, aborts on OOM
|
|
||||||
*/
|
|
||||||
#define VIR_STRDUP_QUIET(dst, src) VIR_STRDUP(dst, src)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* VIR_STRNDUP:
|
|
||||||
* @dst: variable to hold result (char*, not char**)
|
|
||||||
* @src: string to duplicate
|
|
||||||
* @n: the maximum number of bytes to copy
|
|
||||||
*
|
|
||||||
* DEPRECATED: use g_strndup instead
|
|
||||||
*
|
|
||||||
* Duplicate @src string and store it into @dst. If @src is longer than @n,
|
|
||||||
* only @n bytes are copied and terminating null byte '\0' is added. If @n
|
|
||||||
* is a negative number, then the whole @src string is copied. That is,
|
|
||||||
* VIR_STRDUP(dst, src) and VIR_STRNDUP(dst, src, -1) are equal.
|
|
||||||
*
|
|
||||||
* This macro is safe to use on arguments with side effects.
|
|
||||||
*
|
|
||||||
* Returns 0 if @src was NULL, 1 if @src was copied, aborts on OOM
|
|
||||||
*/
|
|
||||||
#define VIR_STRNDUP(dst, src, n) virStrndup(&(dst), src, n)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* VIR_STRNDUP_QUIET:
|
|
||||||
* @dst: variable to hold result (char*, not char**)
|
|
||||||
* @src: string to duplicate
|
|
||||||
* @n: the maximum number of bytes to copy
|
|
||||||
*
|
|
||||||
* DEPRECATED: use g_strndup instead
|
|
||||||
*
|
|
||||||
* Duplicate @src string and store it into @dst. If @src is longer than @n,
|
|
||||||
* only @n bytes are copied and terminating null byte '\0' is added. If @n
|
|
||||||
* is a negative number, then the whole @src string is copied. That is,
|
|
||||||
* VIR_STRDUP_QUIET(dst, src) and VIR_STRNDUP_QUIET(dst, src, -1) are
|
|
||||||
* equal.
|
|
||||||
*
|
|
||||||
* This macro is safe to use on arguments with side effects.
|
|
||||||
*
|
|
||||||
* Returns 0 if @src was NULL, 1 if @src was copied, aborts on OOM
|
|
||||||
*/
|
|
||||||
#define VIR_STRNDUP_QUIET(dst, src, n) virStrndup(&(dst), src, n)
|
|
||||||
|
|
||||||
size_t virStringListLength(const char * const *strings);
|
size_t virStringListLength(const char * const *strings);
|
||||||
|
|
||||||
int virStringSortCompare(const void *a, const void *b);
|
int virStringSortCompare(const void *a, const void *b);
|
||||||
|
Loading…
Reference in New Issue
Block a user