提交 a6d386eb 编写于 作者: J Jonathon Jongsma 提交者: Ján Tomko

util: string: use #pragma once in headers

Signed-off-by: NJonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 1141bfd2
...@@ -16,12 +16,11 @@ ...@@ -16,12 +16,11 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIBVIRT_VIRSTRING_H #pragma once
# define LIBVIRT_VIRSTRING_H
# include <stdarg.h> #include <stdarg.h>
# include "internal.h" #include "internal.h"
char **virStringSplitCount(const char *string, char **virStringSplitCount(const char *string,
const char *delim, const char *delim,
...@@ -126,7 +125,7 @@ int virStrncpy(char *dest, const char *src, size_t n, size_t destbytes) ...@@ -126,7 +125,7 @@ int virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_RETURN_CHECK;
int virStrcpy(char *dest, const char *src, size_t destbytes) int virStrcpy(char *dest, const char *src, size_t destbytes)
ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_RETURN_CHECK;
# define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest)) #define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
/* Don't call these directly - use the macros below */ /* Don't call these directly - use the macros below */
int virStrdup(char **dest, const char *src, bool report, int domcode, int virStrdup(char **dest, const char *src, bool report, int domcode,
...@@ -159,8 +158,8 @@ int virVasprintfInternal(bool report, int domcode, const char *filename, ...@@ -159,8 +158,8 @@ int virVasprintfInternal(bool report, int domcode, const char *filename,
* Returns -1 on failure (with OOM error reported), 0 if @src was NULL, * Returns -1 on failure (with OOM error reported), 0 if @src was NULL,
* 1 if @src was copied * 1 if @src was copied
*/ */
# define VIR_STRDUP(dst, src) virStrdup(&(dst), src, true, VIR_FROM_THIS, \ #define VIR_STRDUP(dst, src) virStrdup(&(dst), src, true, VIR_FROM_THIS, \
__FILE__, __FUNCTION__, __LINE__) __FILE__, __FUNCTION__, __LINE__)
/** /**
* VIR_STRDUP_QUIET: * VIR_STRDUP_QUIET:
...@@ -173,7 +172,7 @@ int virVasprintfInternal(bool report, int domcode, const char *filename, ...@@ -173,7 +172,7 @@ int virVasprintfInternal(bool report, int domcode, const char *filename,
* *
* Returns -1 on failure, 0 if @src was NULL, 1 if @src was copied * Returns -1 on failure, 0 if @src was NULL, 1 if @src was copied
*/ */
# define VIR_STRDUP_QUIET(dst, src) virStrdup(&(dst), src, false, 0, NULL, NULL, 0) #define VIR_STRDUP_QUIET(dst, src) virStrdup(&(dst), src, false, 0, NULL, NULL, 0)
/** /**
* VIR_STRNDUP: * VIR_STRNDUP:
...@@ -191,9 +190,9 @@ int virVasprintfInternal(bool report, int domcode, const char *filename, ...@@ -191,9 +190,9 @@ int virVasprintfInternal(bool report, int domcode, const char *filename,
* Returns -1 on failure (with OOM error reported), 0 if @src was NULL, * Returns -1 on failure (with OOM error reported), 0 if @src was NULL,
* 1 if @src was copied * 1 if @src was copied
*/ */
# define VIR_STRNDUP(dst, src, n) virStrndup(&(dst), src, n, true, \ #define VIR_STRNDUP(dst, src, n) virStrndup(&(dst), src, n, true, \
VIR_FROM_THIS, __FILE__, \ VIR_FROM_THIS, __FILE__, \
__FUNCTION__, __LINE__) __FUNCTION__, __LINE__)
/** /**
* VIR_STRNDUP_QUIET: * VIR_STRNDUP_QUIET:
...@@ -211,8 +210,8 @@ int virVasprintfInternal(bool report, int domcode, const char *filename, ...@@ -211,8 +210,8 @@ int virVasprintfInternal(bool report, int domcode, const char *filename,
* *
* Returns -1 on failure, 0 if @src was NULL, 1 if @src was copied * Returns -1 on failure, 0 if @src was NULL, 1 if @src was copied
*/ */
# define VIR_STRNDUP_QUIET(dst, src, n) virStrndup(&(dst), src, n, false, \ #define VIR_STRNDUP_QUIET(dst, src, n) virStrndup(&(dst), src, n, false, \
0, NULL, NULL, 0) 0, NULL, NULL, 0)
size_t virStringListLength(const char * const *strings); size_t virStringListLength(const char * const *strings);
...@@ -225,7 +224,7 @@ size_t virStringListLength(const char * const *strings); ...@@ -225,7 +224,7 @@ size_t virStringListLength(const char * const *strings);
* Returns -1 on failure (with OOM error reported), number of bytes printed * Returns -1 on failure (with OOM error reported), number of bytes printed
* on success. * on success.
*/ */
# define virVasprintf(strp, fmt, list) \ #define virVasprintf(strp, fmt, list) \
virVasprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, \ virVasprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, \
__LINE__, strp, fmt, list) __LINE__, strp, fmt, list)
...@@ -236,7 +235,7 @@ size_t virStringListLength(const char * const *strings); ...@@ -236,7 +235,7 @@ size_t virStringListLength(const char * const *strings);
* *
* Returns -1 on failure, number of bytes printed on success. * Returns -1 on failure, number of bytes printed on success.
*/ */
# define virVasprintfQuiet(strp, fmt, list) \ #define virVasprintfQuiet(strp, fmt, list) \
virVasprintfInternal(false, 0, NULL, NULL, 0, strp, fmt, list) virVasprintfInternal(false, 0, NULL, NULL, 0, strp, fmt, list)
/** /**
...@@ -251,7 +250,7 @@ size_t virStringListLength(const char * const *strings); ...@@ -251,7 +250,7 @@ size_t virStringListLength(const char * const *strings);
* on success. * on success.
*/ */
# define virAsprintf(strp, ...) \ #define virAsprintf(strp, ...) \
virAsprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__, \ virAsprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__, \
strp, __VA_ARGS__) strp, __VA_ARGS__)
...@@ -265,7 +264,7 @@ size_t virStringListLength(const char * const *strings); ...@@ -265,7 +264,7 @@ size_t virStringListLength(const char * const *strings);
* Returns -1 on failure, number of bytes printed on success. * Returns -1 on failure, number of bytes printed on success.
*/ */
# define virAsprintfQuiet(strp, ...) \ #define virAsprintfQuiet(strp, ...) \
virAsprintfInternal(false, 0, NULL, NULL, 0, \ virAsprintfInternal(false, 0, NULL, NULL, 0, \
strp, __VA_ARGS__) strp, __VA_ARGS__)
...@@ -324,7 +323,5 @@ int virStringParseYesNo(const char *str, ...@@ -324,7 +323,5 @@ int virStringParseYesNo(const char *str,
* Declares a NULL-terminated list of strings which will be automatically freed * Declares a NULL-terminated list of strings which will be automatically freed
* when the pointer goes out of scope. * when the pointer goes out of scope.
*/ */
# define VIR_AUTOSTRINGLIST \ #define VIR_AUTOSTRINGLIST \
__attribute__((cleanup(virStringListAutoFree))) char ** __attribute__((cleanup(virStringListAutoFree))) char **
#endif /* LIBVIRT_VIRSTRING_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册