libgeda

s_weakref.c File Reference

Utility functions for weak references and pointers. More...

#include <config.h>
#include "libgeda_priv.h"
Include dependency graph for s_weakref.c:

Go to the source code of this file.

Data Structures

struct  WeakRef

Functions

void s_weakref_notify (void *dead_ptr, GList *weak_refs)
 Notify weak reference watchers that a structure is dead.
GList * s_weakref_add (GList *weak_refs, void(*notify_func)(void *, void *), void *user_data)
 Add a weak reference watcher to a weak ref list.
GList * s_weakref_remove (GList *weak_refs, void(*notify_func)(void *, void *), void *user_data)
 Remove a weak reference watcher from a weak ref list.
static void weak_ptr_notify_func (void *dead_ptr, void *user_data)
GList * s_weakref_add_ptr (GList *weak_refs, void **weak_pointer_loc)
 Add a weak pointer to a weak ref list.
GList * s_weakref_remove_ptr (GList *weak_refs, void **weak_pointer_loc)
 Remove a weak pointer from a weak ref list.

Detailed Description

Warning:
Do not write code which relies on the order in which weak reference callback functions are notified.

Definition in file s_weakref.c.


Function Documentation

void s_weakref_notify ( void *  dead_ptr,
GList *  weak_refs 
)
Function Description
For each entry in weak_refs, call notify function with the dead pointer dead_ptr and the entry's specified user data, and free weak_refs. Should be called during destruction of an structure that allows weak references.
Parameters:
[in]dead_ptrPointer to structure being destroyed.
[in,out]weak_refsList of registered weak references.

Definition at line 48 of file s_weakref.c.

GList* s_weakref_add ( GList *  weak_refs,
void(*)(void *, void *)  notify_func,
void *  user_data 
)
Function Description
Adds the weak reference callback notify_func to the weak reference list weak_refs, returning the new head of weak_refs. notify_func will be called with two arguments: a pointer to the object being destroyed, and the user_data.
Parameters:
[in,out]weak_refsList of registered weak references.
[in]notify_funcWeak reference notify function.
[in]user_dataData to be passed to notify_func.
Returns:
new head of weak_refs list.

Definition at line 76 of file s_weakref.c.

GList* s_weakref_remove ( GList *  weak_refs,
void(*)(void *, void *)  notify_func,
void *  user_data 
)
Function Description
Removes a weak reference callback from the weak reference list weak_refs, returning the new head of weak_refs.
Parameters:
[in,out]weak_refsList of registered weak references.
[in]notify_funcNotify function to search for.
[in]user_dataUser data to search for.
Returns:
new head of weak_refs list.

Definition at line 97 of file s_weakref.c.

static void weak_ptr_notify_func ( void *  dead_ptr,
void *  user_data 
) [static]

Definition at line 115 of file s_weakref.c.

GList* s_weakref_add_ptr ( GList *  weak_refs,
void **  weak_pointer_loc 
)
Function Description
Adds a weak reference for weak_pointer_loc to the weak reference list weak_refs, returning the new head of weak_refs.
Parameters:
[in,out]weak_refsList of registered weak references.
[in]weak_pointer_locMemory address of a pointer.
Returns:
new head of weak_refs list.

Definition at line 133 of file s_weakref.c.

Here is the call graph for this function:

GList* s_weakref_remove_ptr ( GList *  weak_refs,
void **  weak_pointer_loc 
)
Function Description
Removes the weak reference for weak_pointer_loc from the weak reference list weak_refs, returning the new head of weak_refs.
Parameters:
[in,out]weak_refsList of registered weak references.
[in]weak_pointer_locMemory address of a pointer.
Returns:
new head of weak_refs list.

Definition at line 150 of file s_weakref.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines