From: Ján Tomko Date: Fri, 18 Oct 2019 21:12:19 +0000 (+0200) Subject: docs: hacking: mention GLib alternatives of libvirt allocation macros X-Git-Tag: v5.9.0-rc1~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48f48b27afe97284d2ba8208663320c8f0554421;p=thirdparty%2Flibvirt.git docs: hacking: mention GLib alternatives of libvirt allocation macros 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 --- 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