Function
GObjectClosurenew_simple
Declaration [src]
GClosure*
g_closure_new_simple (
  guint sizeof_closure,
  gpointer data
)
Description [src]
Allocates a struct of the given size and initializes the initial
part as a GClosure.
This function is mainly useful when implementing new types of closures:
typedef struct _MyClosure MyClosure;
struct _MyClosure
{
  GClosure closure;
  // extra data goes here
};
static void
my_closure_finalize (gpointer  notify_data,
                     GClosure *closure)
{
  MyClosure *my_closure = (MyClosure *)closure;
  // free extra data here
}
MyClosure *my_closure_new (gpointer data)
{
  GClosure *closure;
  MyClosure *my_closure;
  closure = g_closure_new_simple (sizeof (MyClosure), data);
  my_closure = (MyClosure *) closure;
  // initialize extra data here
  g_closure_add_finalize_notifier (closure, notify_data,
                                   my_closure_finalize);
  return my_closure;
}
Parameters
- sizeof_closure
- 
            Type: guintThe size of the structure to allocate, must be at least sizeof (GClosure).
- data
- 
            Type: gpointerData to store in the datafield of the newly allocatedGClosure.The argument can be NULL.The data is owned by the caller of the function. 
Return value
Type: GClosure
A floating reference to a new GClosure.
| The data is owned by the called function. |