CUBRID Engine  latest
api_util.h File Reference
#include <pthread.h>
#include <stdio.h>
Include dependency graph for api_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dlisth_s
 

Macros

#define dlisth_init(h)
 
#define dlisth_is_empty(h)   ((h)->next == (h) && (h)->prev == (h))
 
#define dlisth_delete(h_)
 
#define dlisth_insert_before(ih, bh)
 
#define dlisth_insert_after(ih, bh)
 
#define API_MUTEX   pthread_mutex_t
 
#define API_MUTEX_INIT(m)   pthread_mutex_init(m,NULL)
 
#define API_MUTEX_INITIALIZER   PTHREAD_MUTEX_INITIALIZER
 
#define API_LOCK(m)   pthread_mutex_lock(m)
 
#define API_UNLOCK(m)   pthread_mutex_unlock(m)
 
#define API_TRYLOCK(m)   pthread_mutex_trylock(m)
 
#define API_MUTEX_DESTROY(m)   pthread_mutex_destroy(m)
 
#define API_ONCE_TYPE   pthread_once_t
 
#define API_ONCE_INIT   PTHREAD_ONCE_INIT
 
#define API_ONCE_FUNC(t, r)   pthread_once(t,r)
 
#define API_CALLOC(n, s)   api_calloc((n),(s),__FILE__,__LINE__)
 
#define API_MALLOC(s)   api_malloc((s),__FILE__,__LINE__)
 
#define API_FREE(p)   api_free((p), __FILE__, __LINE__)
 

Typedefs

typedef struct dlisth_s dlisth
 
typedef int(* dlist_map_func) (dlisth *h, void *arg, int *cont)
 
typedef struct hash_table_s hash_table
 
typedef int(* ht_comparef) (void *key1, void *key2, int *r)
 
typedef int(* ht_hashf) (void *key, unsigned int *rv)
 
typedef int(* ht_keyf) (void *elem, void **rk)
 
typedef void(* ht_destroyf) (void *elem)
 

Functions

int dlisth_map (dlisth *h, dlist_map_func func, void *arg)
 
int hash_new (int bucket_sz, ht_hashf hashf, ht_keyf keyf, ht_comparef comparef, hash_table **ht)
 
void hash_destroy (hash_table *ht, ht_destroyf dtor)
 
int hash_lookup (hash_table *ht, void *key, void **elem)
 
int hash_insert (hash_table *ht, void *elem)
 
int hash_delete (hash_table *ht, void *key, void **elem)
 
void * api_calloc (size_t nmemb, size_t size, const char *file, int line)
 
void * api_malloc (size_t size, const char *file, int line)
 
void api_free (void *ptr, const char *file, int line)
 
int api_check_memory (FILE *fp)
 

Variables

int api_malloc_dhook_flag_set
 

Macro Definition Documentation

#define API_LOCK (   m)    pthread_mutex_lock(m)
#define API_MUTEX   pthread_mutex_t

Definition at line 97 of file api_util.h.

#define API_MUTEX_DESTROY (   m)    pthread_mutex_destroy(m)

Definition at line 103 of file api_util.h.

#define API_MUTEX_INIT (   m)    pthread_mutex_init(m,NULL)

Definition at line 98 of file api_util.h.

Referenced by once_function(), and rr_init_root().

#define API_MUTEX_INITIALIZER   PTHREAD_MUTEX_INITIALIZER

Definition at line 99 of file api_util.h.

#define API_ONCE_FUNC (   t,
 
)    pthread_once(t,r)

Definition at line 106 of file api_util.h.

Referenced by api_calloc(), api_check_memory(), api_free(), and api_malloc().

#define API_ONCE_INIT   PTHREAD_ONCE_INIT

Definition at line 105 of file api_util.h.

#define API_ONCE_TYPE   pthread_once_t

Definition at line 104 of file api_util.h.

#define API_TRYLOCK (   m)    pthread_mutex_trylock(m)

Definition at line 102 of file api_util.h.

Referenced by bh_root_lock().

#define API_UNLOCK (   m)    pthread_mutex_unlock(m)
#define dlisth_delete (   h_)
Value:
do { \
dlisth *__h = (h_); \
(__h)->next->prev = (__h)->prev; \
(__h)->prev->next = (__h)->next; \
(__h)->next = (__h)->prev = (__h); \
} while(0)
dlisth * prev
Definition: api_util.h:34
dlisth * next
Definition: api_util.h:33
struct dlisth_s dlisth
Definition: api_util.h:30

Definition at line 50 of file api_util.h.

Referenced by api_free(), hash_delete(), hash_destroy(), li_api_delete(), li_api_destroy(), and stmt_complete_batch().

#define dlisth_init (   h)
Value:
do { \
dlisth *__h = (h); \
(__h)->next = (__h)->prev = (__h); \
} while (0)
dlisth * prev
Definition: api_util.h:34
struct dlisth_s dlisth
Definition: api_util.h:30

Definition at line 42 of file api_util.h.

Referenced by ci_stmt_add_batch_impl(), ci_stmt_add_batch_query_impl(), create_handle_context(), hash_new(), init_statement_impl(), li_api_insert(), list_indexer_create(), make_debug_h(), once_function(), and stmt_complete_batch().

#define dlisth_insert_after (   ih,
  bh 
)
Value:
do { \
dlisth *__ih = (ih); \
dlisth *__bh = (bh); \
(__ih)->prev = (__bh); \
(__ih)->next = (__bh)->next; \
(__bh)->next->prev = (__ih); \
(__bh)->next = (__ih); \
} while (0)
dlisth * prev
Definition: api_util.h:34
dlisth * next
Definition: api_util.h:33
struct dlisth_s dlisth
Definition: api_util.h:30

Definition at line 68 of file api_util.h.

Referenced by api_calloc(), api_malloc(), fe_alloc_handle(), hash_insert(), li_api_insert(), and stmt_complete_batch().

#define dlisth_insert_before (   ih,
  bh 
)
Value:
do { \
dlisth *__ih = (ih); \
dlisth *__bh = (bh); \
(__ih)->next = (__bh); \
(__ih)->prev = (__bh)->prev; \
(__bh)->prev->next = (__ih); \
(__bh)->prev = (__ih); \
} while (0)
dlisth * prev
Definition: api_util.h:34
dlisth * next
Definition: api_util.h:33
struct dlisth_s dlisth
Definition: api_util.h:30

Definition at line 58 of file api_util.h.

Referenced by ci_stmt_add_batch_impl(), ci_stmt_add_batch_query_impl(), and fe_bind_graft().

#define dlisth_is_empty (   h)    ((h)->next == (h) && (h)->prev == (h))

Typedef Documentation

typedef int(* dlist_map_func) (dlisth *h, void *arg, int *cont)

Definition at line 38 of file api_util.h.

typedef struct dlisth_s dlisth

Definition at line 30 of file api_util.h.

typedef struct hash_table_s hash_table

Definition at line 80 of file api_util.h.

typedef int(* ht_comparef) (void *key1, void *key2, int *r)

Definition at line 82 of file api_util.h.

typedef void(* ht_destroyf) (void *elem)

Definition at line 88 of file api_util.h.

typedef int(* ht_hashf) (void *key, unsigned int *rv)

Definition at line 84 of file api_util.h.

typedef int(* ht_keyf) (void *elem, void **rk)

Definition at line 86 of file api_util.h.

Function Documentation

void* api_calloc ( size_t  nmemb,
size_t  size,
const char *  file,
int  line 
)
int api_check_memory ( FILE *  fp)
void api_free ( void *  ptr,
const char *  file,
int  line 
)
void* api_malloc ( size_t  size,
const char *  file,
int  line 
)
int dlisth_map ( dlisth h,
dlist_map_func  func,
void *  arg 
)

Definition at line 138 of file api_util.c.

References assert, dlisth_s::next, NO_ERROR, and NULL.

Referenced by li_api_map().

Here is the caller graph for this function:

int hash_delete ( hash_table ht,
void *  key,
void **  elem 
)
void hash_destroy ( hash_table ht,
ht_destroyf  dtor 
)
int hash_insert ( hash_table ht,
void *  elem 
)
int hash_lookup ( hash_table ht,
void *  key,
void **  elem 
)
int hash_new ( int  bucket_sz,
ht_hashf  hashf,
ht_keyf  keyf,
ht_comparef  comparef,
hash_table **  ht 
)

Variable Documentation

int api_malloc_dhook_flag_set

Definition at line 79 of file api_util.c.

Referenced by api_calloc(), api_check_memory(), api_free(), and api_malloc().