libcstl
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
memory.h File Reference

Go to the source code of this file.

Data Structures

struct  cstl_guarded_ptr
 Structure to hold a pointer and guard against its direct copying. More...
 
struct  cstl_unique_ptr_t
 A pointer that has a single "owner". More...
 
struct  cstl_shared_ptr_t
 The shared pointer object. More...
 

Macros

#define CSTL_GUARDED_PTR_INITIALIZER(NAME)
 Initialize (at compile-time) a guarded pointer object.
 
#define DECLARE_CSTL_GUARDED_PTR(NAME)
 Declare and initialize a guarded pointer.
 
#define CSTL_UNIQUE_PTR_INITIALIZER(NAME)
 Initialize (at compile time) a unique pointer.
 
#define DECLARE_CSTL_UNIQUE_PTR(NAME)
 Declare and initialize a unique pointer.
 
#define CSTL_SHARED_PTR_INITIALIZER(NAME)
 Compile-time initialization of a declared shared pointer.
 
#define DECLARE_CSTL_SHARED_PTR(NAME)    cstl_shared_ptr_t NAME = CSTL_SHARED_PTR_INITIALIZER(NAME)
 Compile-time declaration and initialization of a shared pointer.
 
#define CSTL_WEAK_PTR_INITIALIZER(NAME)    CSTL_SHARED_PTR_INITIALIZER(NAME)
 Compile-time initialization of a weak pointer.
 
#define DECLARE_CSTL_WEAK_PTR(NAME)    cstl_weak_ptr_t NAME = CSTL_WEAK_PTR_INITIALIZER(NAME)
 Compile-time declaration and initialization of a weak pointer.
 

Typedefs

typedef cstl_shared_ptr_t cstl_weak_ptr_t
 The weak pointer object.
 

Functions

static void cstl_guarded_ptr_set (struct cstl_guarded_ptr *const gp, void *const ptr)
 Initialize a guarded pointer object to a specific pointer value.
 
static void cstl_guarded_ptr_init (struct cstl_guarded_ptr *const gp)
 Initialize a guarded pointer object to NULL.
 
static const void * cstl_guarded_ptr_get_const (const struct cstl_guarded_ptr *const gp)
 Retrieve the stored pointer value.
 
static void * cstl_guarded_ptr_get (struct cstl_guarded_ptr *const gp)
 Retrieve the stored pointer value.
 
static void cstl_guarded_ptr_copy (struct cstl_guarded_ptr *const dst, const struct cstl_guarded_ptr *const src)
 Copy the cstl_guarded_ptr object to a new location.
 
static void cstl_guarded_ptr_swap (struct cstl_guarded_ptr *const a, struct cstl_guarded_ptr *const b)
 Swap the pointers pointed to by the objects.
 
static void cstl_unique_ptr_init (cstl_unique_ptr_t *const up)
 Initialize a unique pointer.
 
void cstl_unique_ptr_alloc (cstl_unique_ptr_t *up, size_t len, cstl_xtor_func_t *clr, void *priv)
 Dynamically allocate memory to be managed by the unique pointer.
 
static const void * cstl_unique_ptr_get_const (const cstl_unique_ptr_t *const up)
 Get the pointer managed by the unique pointer object.
 
static void * cstl_unique_ptr_get (cstl_unique_ptr_t *const up)
 Get the pointer managed by the unique pointer object.
 
static void * cstl_unique_ptr_release (cstl_unique_ptr_t *const up, cstl_xtor_func_t **const clr, void **priv)
 Stop a unique pointer object from managing a pointer.
 
static void cstl_unique_ptr_swap (cstl_unique_ptr_t *const up1, cstl_unique_ptr_t *const up2)
 Swap the objects pointed to by the parameters.
 
void cstl_unique_ptr_reset (cstl_unique_ptr_t *up)
 Free the memory managed by a unique pointer.
 
static void cstl_shared_ptr_init (cstl_shared_ptr_t *const sp)
 Initialize a shared pointer object.
 
void cstl_shared_ptr_alloc (cstl_shared_ptr_t *sp, size_t sz, cstl_xtor_func_t *clr)
 Dynamically allocated memory to be shared via the object.
 
bool cstl_shared_ptr_unique (const cstl_shared_ptr_t *sp)
 Determine if a shared pointer uniquely owns the underlying memory.
 
const void * cstl_shared_ptr_get_const (const cstl_shared_ptr_t *)
 Get a pointer to the memory managed by the object.
 
static void * cstl_shared_ptr_get (cstl_shared_ptr_t *const sp)
 Get a pointer to the memory managed by the object.
 
void cstl_shared_ptr_share (const cstl_shared_ptr_t *ex, cstl_shared_ptr_t *n)
 Create a new shared pointer object to manage the underlying memory.
 
static void cstl_shared_ptr_swap (cstl_shared_ptr_t *const sp1, cstl_shared_ptr_t *const sp2)
 Swap the memory managed by the two objects.
 
void cstl_shared_ptr_reset (cstl_shared_ptr_t *sp)
 Stop managing the underlying memory via this object.
 
static void cstl_weak_ptr_init (cstl_weak_ptr_t *const wp)
 Initialize a weak pointer object.
 
void cstl_weak_ptr_from (cstl_weak_ptr_t *wp, const cstl_shared_ptr_t *sp)
 Create a weak pointer from a shared pointer.
 
void cstl_weak_ptr_lock (const cstl_weak_ptr_t *wp, cstl_shared_ptr_t *sp)
 Convert a weak pointer to a shared pointer.
 
static void cstl_weak_ptr_swap (cstl_weak_ptr_t *const wp1, cstl_weak_ptr_t *const wp2)
 Swap the memory managed by the two weak pointer objects.
 
void cstl_weak_ptr_reset (cstl_weak_ptr_t *)
 Drop the reference to the underlying managed memory.