libvips icon indicating copy to clipboard operation
libvips copied to clipboard

Use glib autoptr

Open jcupitt opened this issue 2 years ago • 0 comments

We could start using glib's autoptr system. We'd need to require compiler support in meson.build with something like:

  cc.has_header_symbol(
    'glib.h', 'G_DEFINE_AUTOPTR_CLEANUP_FUNC',
    dependencies : glib_dep,
    required : true,
  )

gcc and clang both support this, I'm not sure about other compilers.

autoptr is a nice way to automatically trigger cleanup functions for values allocated on the stack. It makes code easier to read and removes a class of memory leaks.

jcupitt avatar Jun 20 '23 09:06 jcupitt