[libvirt] [PATCH 09/16] docs: hacking: mention GLib alternatives of libvirt string allocation macros

Ján Tomko jtomko at redhat.com
Fri Oct 18 22:36:43 UTC 2019


Document the preferred alternatives to existing libvirt macros for
allocating strings. These cannot be deleted just yet because
converting them will require a lot of work.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 docs/hacking.html.in | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index f39f6433d4..d4f1c2baad 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -1071,6 +1071,18 @@ BAD:
         <tr><td><code>VIR_FREE</code></td><td><code>g_free</code></td>
             <td><code>g_free</code> does not zero the pointer</td></tr>
     </table>
+
+    <p>String allocation macros and functions:</p>
+    <table class="top_table">
+        <tr><th>deprecated version</th><th>GLib version</th><th>Notes</th></tr>
+        <tr><td><code>VIR_STRDUP</code></td><td><code>g_strdup</code></td><td></td></tr>
+        <tr><td><code>VIR_STRNDUP</code></td><td><code>g_strndup</code></td><td></td></tr>
+        <tr><td><code>virAsprintf</code></td><td><code>g_strdup_printf</code></td><td></td></tr>
+        <tr><td><code>virVasprintf</code></td><td><code>g_strdup_vprint</code></td>
+            <td>use <code>g_vasprintf</code> if you really need to know the returned length</td></tr>
+        <tr><td><code>virStrerror</code></td><td><code>g_strerror</code></td>
+            <td>the error strings are cached globally so no need to free it</td></tr>
+    </table>
     </dl>
 
     <p>
-- 
2.21.0




More information about the libvir-list mailing list