> On Nov 2, 2020, at 6:47 PM, Barrett J Schonefeld <bschoney@xxxxxxxxxx> wrote: > > Hey folks, > > We have started work on issue 11, and we have some questions to ensure we tackle the issue properly. > > • What are the different use cases for g_autoptr vs g_autofree? We found that g_autofree is preferred for anything that uses g_malloc according to the Glib documentation, and g_autoptr is for types with custom destructors. However, when using g_autoptr, we got compile errors when trying to pass the g_autoptr as an argument (the argument seems to be converted to an integer). When should we use each of these, and when should we not convert them at all? To use g_autoptr(), the cleanup function for that type has to have been declared using G_DEFINE_AUTOPTR_CLEANUP_FUNC(): https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#G-DEFINE-AUTOPTR-CLEANUP-FUNC:CAPS This hasn't been done for all of libvirt's types yet, so you have to look at the type's code to see if you can declare variables with g_autoptr() or if you still have to manually manage their memory. I'm a new contributor, as well. I've found myself doing a ton of codebase-wide searches. Using rg (ripgrep) instead of grep has saved me a ton of time, so I suggest giving it a try if you don't already use it. > • We see that some work has been done to convert files to use the Glib API. In some cases, files contain code that uses both the old memory management API and the Glib API. Should we focus our attention on files where these conversions are not yet underway? Or should we expect that many of the files are only partially converted? I've been working on the Hyper-V API and it was partially converted when I started. I've been gradually moving existing unconverted code to GLib as I update it and using GLib for anything new that I add. Daniel P. Berrangé has a blog with some very helpful articles about the modernization of libvirt's codebase, including automatic cleanup functionality: https://www.berrange.com/tags/kvmforum2019/ I don't think I have enough experience with this codebase to weigh in on your other questions. -- Matt