-1

recently we planned to upgrade glib library to latest version : 2.64

We have built the library and try to use the same in our build infrastructure. While running build we are getting errors :-

error: 'g_mem_chunk_alloc0' is deprecated
error: 'g_mem_chunk_free' is deprecated
error: 'g_mem_chunk_alloc' is deprecated 
error: 'g_atexit' is deprecated 

How could we find the replacement of those deprecated functions in newer glib version?

Naga
  • 59
  • 8
  • Show some [mre] in your question. Explain why do you need to use `g_mem_chunk_alloc0` instead of `calloc` or `malloc`, and `g_memchunk_free` instead of `free`. Consider using [atexit(3)](https://man7.org/linux/man-pages/man3/atexit.3.html). Your question is operating system specific. – Basile Starynkevitch Jun 16 '20 at 04:55
  • Those symbols are being used from new glib library. With older glib library version those symbols were supported and with newer one they are not.... So we are facing deprecated function errors. For those deprecated functions there should be some replacement function with new glib. I could not find that info from glib docs. So posted here if could get some help. – Naga Jun 16 '20 at 05:46
  • Did you *carefully* read the [documentation of Glib](https://developer.gnome.org/glib/stable/) ? It is open source, so did you study its source code? You are allowed to improve Glib for your needs, per its [LGPLv2.1](https://github.com/GNOME/glib/blob/mainline/COPYING) license – Basile Starynkevitch Jun 16 '20 at 05:48
  • 1
    https://developer.gnome.org/glib/stable/glib-Memory-Slices.html should provide similar-ish API – Jussi Kukkonen Jun 16 '20 at 07:42
  • Jussi, But the above link dont have clear info like replacement of 'g_mem_chunk_free' is so and so function... How could we find that exact info? Shall i consider g_slice_alloc as a replacement of g_mem_chunk_alloc ? – Naga Jun 16 '20 at 08:00

1 Answers1

0
error: 'g_mem_chunk_alloc0' is deprecated
error: 'g_mem_chunk_free' is deprecated
error: 'g_mem_chunk_alloc' is deprecated 

The g_mem_chunk_*() APIs were deprecated in 2005 (15 years ago), and all mention of them was removed from the documentation in 2011 (9 years ago).

I don’t think it’s reasonable to keep documentation for deprecated functions around for 15 years (it would cause more confusion than it would solve).

The GSlice API is the replacement for GMemChunk. In particular: * g_mem_chunk_alloc0()g_slice_alloc0() * g_mem_chunk_free()g_slice_free() * g_mem_chunk_alloc()g_slice_alloc()

These won’t be 1:1 replacements for the deprecated APIs, as otherwise the developers at the time could have avoided deprecating those APIs. You will likely have to rework your code.


error: 'g_atexit' is deprecated 

The documentation for g_atexit() explains that there is no replacement for it:

The behaviour of atexit() in the context of dynamically loaded modules is not formally specified and varies wildly.

Philip Withnall
  • 5,293
  • 14
  • 28