On Mon, Oct 07, 2019 at 06:14:06PM +0100, Daniel P. Berrangé wrote:
Convert the string duplication APIs to use the g_strdup family of
APIs.
We previously used the 'strdup-posix' gnulib module because mingw does
not set errno to ENOMEM on failure
We previously used the 'strndup' gnulib module because this function
does not exist on mingw.
We previously used the 'vasprintf' gnulib module because of many GNU
supported format specifiers not working on non-Linux platforms. glib's
own equivalent standardizes on GNU format specifiers too.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
bootstrap.conf | 3 ---
docs/hacking.html.in | 8 ++++++++
src/util/virstring.c | 28 ++++++++++++++++++++++------
src/util/virstring.h | 8 ++++++++
4 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index b98fdedeb1..7105ae2eeb 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -82,8 +82,6 @@ snprintf
socket
stat-time
strchrnul
-strdup-posix
-strndup
strerror
strerror_r-posix
strptime
@@ -99,7 +97,6 @@ uname
unsetenv
useless-if-before-free
usleep
-vasprintf
verify
vc-list-files
vsnprintf
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 8072796312..5839464e99 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -1020,6 +1020,14 @@ BAD:
classic libvirt memory allocation APIs and GLib APIs within
a single method. Keep the style consistent, converting existing
code to GLib style in a separate, prior commit.</dd>
+
+ <dt>VIR_STRDUP, VIR_STRNDUP</dt>
+ <dd>Prefer the GLib APIs g_strdup and g_strndup.</dd>
+
+ <dt>virAsprintf, virVasprintf</dt>
+ <dd>The GLib APIs g_strdup_printf / g_strdup_vprint can be used,
+ but beware that they don't abort on OOM, so the libvirt wrappers
+ may still be desirable to use. Don't use g_vasprintf or
g_asprintf.</dd>
What do you mean by g_asprintf? I cannot find that function.
</dl>
<h2><a id="file_handling">File handling</a></h2>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano