Why use GLib functions?

后端 未结 7 527
野的像风
野的像风 2021-01-31 17:30

While programming in C and GTK+, why is it \"better\" to use g_strdup_printf, g_free, g_strcmp0 etc... and fellow GLib functions?

7条回答
  •  不思量自难忘°
    2021-01-31 17:46

    Here is an update. It looks the developer's realized their mistake:

    g_mem_is_system_malloc has been deprecated since version 2.46 and should not be used in newly-written code.

    GLib always uses the system malloc, so this function always returns TRUE.

    Checks whether the allocator used by g_malloc() is the system's malloc implementation. If it returns TRUE memory allocated with malloc() can be used interchangeable with memory allocated using g_malloc(). This function is useful for avoiding an extra copy of allocated memory returned by a non-GLib-based API.

    https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-mem-is-system-malloc

提交回复
热议问题