mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
add virAsprintf
This commit is contained in:
parent
e4471a7ac7
commit
36c612b21c
@ -1,3 +1,9 @@
|
||||
Mon Dec 15 21:05:56 CET 2008 Guido Günther <agx@sigxcpu.org>
|
||||
|
||||
Add virAsprintf as safer asprintf helper
|
||||
* src/util.c, src/util.h (virAsprintf): new function
|
||||
* src/libvirt_symver.in: export symbol
|
||||
|
||||
Mon Dec 15 16:33:25 CET 2008 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/storage_driver.c: fix a segfault, patch by Miloslav TrmaC
|
||||
|
@ -595,6 +595,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
|
||||
virFileReadPid;
|
||||
virFileLinkPointsTo;
|
||||
virParseNumber;
|
||||
virAsprintf;
|
||||
virRun;
|
||||
virSkipSpaces;
|
||||
|
||||
|
20
src/util.c
20
src/util.c
@ -1153,6 +1153,26 @@ virParseNumber(const char **str)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* virAsprintf
|
||||
*
|
||||
* like asprintf but makes sure *strp == NULL on failure
|
||||
*/
|
||||
int
|
||||
virAsprintf(char **strp, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
if ((ret = vasprintf(strp, fmt, ap)) == -1)
|
||||
*strp = NULL;
|
||||
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Compare two MAC addresses, ignoring differences in case,
|
||||
* as well as leading zeros.
|
||||
*/
|
||||
|
@ -112,6 +112,7 @@ int virMacAddrCompare (const char *mac1, const char *mac2);
|
||||
|
||||
void virSkipSpaces(const char **str);
|
||||
int virParseNumber(const char **str);
|
||||
int virAsprintf(char **strp, const char *fmt, ...);
|
||||
|
||||
#define VIR_MAC_BUFLEN 6
|
||||
#define VIR_MAC_PREFIX_BUFLEN 3
|
||||
|
Loading…
Reference in New Issue
Block a user