]> xenbits.xensource.com Git - libvirt.git/commitdiff
docs: hacking: mention GLib alternatives of libvirt string allocation macros
authorJán Tomko <jtomko@redhat.com>
Fri, 18 Oct 2019 21:12:19 +0000 (23:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 22 Oct 2019 20:15:02 +0000 (22:15 +0200)
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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
docs/hacking.html.in

index 0f4587522d3621d2bdb49b77329b397b1e59e964..d60ea5d120184f2d1f4e05161fb403e9048c51bb 100644 (file)
@@ -1072,6 +1072,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>