[PATCH v2] iface-modem: port mm_iface_modem_wait_for_final_state to use GTask

Aleksander Morgado aleksander at aleksander.es
Fri Jun 30 12:54:13 UTC 2017


On Fri, Jun 30, 2017 at 2:35 PM, Ben Chan <benchan at chromium.org> wrote:
> I noticed a mix use of g_new+g_free vs g_slice_new+g_slice_free in MM
> code. glib doc seems to recommend the latter. For infrequent memory
> allocations, I wonder if there is any practical difference between the
> two. For WaitForFinalStateContext here, it seems like if we use
> g_new+g_free, we can simply use g_free in `g_task_set_task_data(task,
> ctx, g_free)` and get rid of wait_for_final_state_context_free.  Do we
> have a technical or style preference of using g_new vs g_slice_new in
> MM code?

When creating operation contexts I usually tried to use the slice
allocator, but it is true that operations aren't frequent enough and
it makes code much more maintainable if we just use g_free as
GDestroyNotify in g_task_set_task_data(), so I'm happy if we start
doing that as well.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list