From 48f48b27afe97284d2ba8208663320c8f0554421 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Fri, 18 Oct 2019 23:12:19 +0200 Subject: [PATCH] docs: hacking: mention GLib alternatives of libvirt allocation macros MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Document the preferred alternatives to existing libvirt macros for memory allocation. These cannot be deleted just yet because converting them will require a lot of work. Signed-off-by: Ján Tomko Reviewed-by: Andrea Bolognani --- docs/hacking.html.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/hacking.html.in b/docs/hacking.html.in index f3ad43eee7..0f4587522d 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -1051,6 +1051,27 @@ BAD:
virStrerror
The GLib g_strerror() function should be used instead, which has a simpler calling convention as an added benefit.
+ + + + + + + + + + + + + + + + + + + + +
deprecated versionGLib versionNotes
VIR_ALLOC(var)g_new0(var_t, 1)the type needs to be passed explicitly
VIR_ALLOC_Ng_new0(var_t, n)
VIR_REALLOC_Ng_renew(var_t, ptr, n)the newly added memory is not zeroed
VIR_EXPAND_Ng_renew(var_t, ptr, n)zero the new memory manually or use an array type
VIR_SHRINK_Ng_renew(var_t, ptr, n)
VIR_APPEND_ELEMENTg_array_append_valg_ptr_array_add or g_byte_array_append
VIR_INSERT_ELEMENTg_array_insert_valg_ptr_array_insert
VIR_DELETE_ELEMENTg_array_remove_indexg_ptr_array_remove_index or g_byte_array_remove_index
VIR_FREEg_freeg_free does not zero the pointer

-- 2.47.2