CUBRID Engine  latest
api_util.c File Reference
#include "config.h"
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include "api_util.h"
#include "error_code.h"
Include dependency graph for api_util.c:

Go to the source code of this file.

Classes

struct  ht_elem_s
 
struct  ht_bucket_s
 
struct  hash_table_s
 
struct  debug_malloc_h_s
 

Macros

#define MALLOC_HEADER_SZ   32
 

Typedefs

typedef struct ht_elem_s ht_elem
 
typedef struct ht_bucket_s ht_bucket
 
typedef struct debug_malloc_h_s debug_malloc_h
 

Functions

static void once_function ()
 
static void make_debug_h (debug_malloc_h *mh, const char *file, int line)
 
static void dump_debug_h (debug_malloc_h *mh, FILE *fp)
 
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 **rht)
 
void hash_destroy (hash_table *ht, ht_destroyf dtor)
 
int hash_lookup (hash_table *ht, void *key, void **relem)
 
int hash_insert (hash_table *ht, void *elem)
 
int hash_delete (hash_table *ht, void *key, void **relem)
 
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

static API_MUTEX mutex
 
static int malloc_count
 
static int free_count
 
static dlisth malloc_list
 
static API_ONCE_TYPE once = API_ONCE_INIT
 
int api_malloc_dhook_flag_set = 0
 

Macro Definition Documentation

#define MALLOC_HEADER_SZ   32

Definition at line 65 of file api_util.c.

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

Typedef Documentation

Definition at line 35 of file api_util.c.

typedef struct ht_bucket_s ht_bucket

Definition at line 34 of file api_util.c.

typedef struct ht_elem_s ht_elem

Definition at line 33 of file api_util.c.

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:

static void dump_debug_h ( debug_malloc_h mh,
FILE *  fp 
)
static

Definition at line 122 of file api_util.c.

References debug_malloc_h_s::file, and debug_malloc_h_s::line.

Referenced by api_check_memory().

Here is the caller graph for this function:

int hash_delete ( hash_table ht,
void *  key,
void **  relem 
)
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 **  relem 
)
int hash_new ( int  bucket_sz,
ht_hashf  hashf,
ht_keyf  keyf,
ht_comparef  comparef,
hash_table **  rht 
)
static void make_debug_h ( debug_malloc_h mh,
const char *  file,
int  line 
)
static

Definition at line 102 of file api_util.c.

References dlisth_init, debug_malloc_h_s::file, debug_malloc_h_s::head, debug_malloc_h_s::line, and strlen.

Referenced by api_calloc(), and api_malloc().

Here is the caller graph for this function:

static void once_function ( )
static

Definition at line 86 of file api_util.c.

References API_MUTEX_INIT, dlisth_init, free_count, malloc_count, and mutex.

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

Here is the caller graph for this function:

Variable Documentation

int api_malloc_dhook_flag_set = 0

Definition at line 79 of file api_util.c.

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

int free_count
static

Definition at line 74 of file api_util.c.

Referenced by api_check_memory(), api_free(), css_initialize_list(), and once_function().

int malloc_count
static

Definition at line 73 of file api_util.c.

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

dlisth malloc_list
static

Definition at line 75 of file api_util.c.

Definition at line 76 of file api_util.c.

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