YAZ  5.23.1
Macros
shptr.h File Reference

Shared pointer macros. More...

#include <yaz/xmalloc.h>
#include <yaz/mutex.h>

Go to the source code of this file.

Macros

#define YAZ_SHPTR_TYPE(type)
 
#define YAZ_SHPTR_INIT(p, n)
 
#define YAZ_SHPTR_INC(p)
 
#define YAZ_SHPTR_DEC(p, destroy)
 

Detailed Description

Shared pointer macros.

Definition in file shptr.h.

Macro Definition Documentation

#define YAZ_SHPTR_DEC (   p,
  destroy 
)
Value:
{ \
yaz_mutex_enter(p->mutex); \
if (--p->ref == 0) { \
yaz_mutex_leave(p->mutex); \
destroy(p->ptr); \
yaz_mutex_destroy(&p->mutex); \
xfree(p); \
p = 0; \
} else { \
yaz_mutex_leave(p->mutex); \
} \
}
void yaz_mutex_leave(YAZ_MUTEX p)
leave critical section / AKA unlock
Definition: mutex.c:120
void yaz_mutex_enter(YAZ_MUTEX p)
enter critical section / AKA lock
Definition: mutex.c:69
#define xfree(x)
utility macro which calls xfree_f
Definition: xmalloc.h:53
void yaz_mutex_destroy(YAZ_MUTEX *p)
destroy MUTEX
Definition: mutex.c:138

Definition at line 64 of file shptr.h.

Referenced by resultset_destroy(), and ZOOM_record_release().

#define YAZ_SHPTR_INC (   p)
Value:
{ \
yaz_mutex_enter(p->mutex); \
p->ref++; \
yaz_mutex_leave(p->mutex); \
}
void yaz_mutex_leave(YAZ_MUTEX p)
leave critical section / AKA unlock
Definition: mutex.c:120
void yaz_mutex_enter(YAZ_MUTEX p)
enter critical section / AKA lock
Definition: mutex.c:69

Definition at line 58 of file shptr.h.

Referenced by record_cache_add().

#define YAZ_SHPTR_INIT (   p,
 
)
Value:
{ \
p = xmalloc(sizeof(*p)); \
p->ptr = n; \
p->ref = 1; \
p->mutex = 0; \
yaz_mutex_create(&p->mutex); \
}
void yaz_mutex_create(YAZ_MUTEX *p)
create MUTEX
Definition: mutex.c:41
#define xmalloc(x)
utility macro which calls malloc_f
Definition: xmalloc.h:49

Definition at line 50 of file shptr.h.

Referenced by ZOOM_record_get(), and ZOOM_resultset_create().

#define YAZ_SHPTR_TYPE (   type)
Value:
struct type##_shptr \
{ \
type ptr; \
int ref; \
YAZ_MUTEX mutex; \
}; \
typedef struct type##_shptr *type##_shptr_t;
enum l_file_type type
Definition: log.c:45
struct yaz_mutex * YAZ_MUTEX
YAZ MUTEX opaque pointer.
Definition: mutex.h:42

Definition at line 41 of file shptr.h.