Function Macro

GLibDEFINE_AUTO_CLEANUP_FREE_FUNC

Declaration

#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC (
  TypeName,
  func,
  none
)

Description

Defines the appropriate cleanup function for a type.

With this definition, it will be possible to use g_auto() with TypeName.

This function will be rarely used. It is used with pointer-based typedefs and non-pointer types where the value of the variable represents a resource that must be freed. Two examples are GStrv and file descriptors.

none specifies the “none” value for the type in question. It is probably something like NULL or -1. If the variable is found to contain this value then the free function will not be called.

G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)

This macro should be used unconditionally; it is a no-op on compilers where cleanup is not supported.

Available since:2.44

Parameters

TypeName none
 

A type name to define a g_auto() cleanup function for.

func none
 

The free function.

none none
 

The “none” value for the type.