CUBRID Engine
latest
|
#include "config.h"
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include "api_util.h"
#include "error_code.h"
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 |
#define MALLOC_HEADER_SZ 32 |
Definition at line 65 of file api_util.c.
Referenced by api_calloc(), api_free(), and api_malloc().
typedef struct debug_malloc_h_s debug_malloc_h |
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.
Definition at line 33 of file api_util.c.
void* api_calloc | ( | size_t | nmemb, |
size_t | size, | ||
const char * | file, | ||
int | line | ||
) |
Definition at line 366 of file api_util.c.
References API_LOCK, api_malloc_dhook_flag_set, API_ONCE_FUNC, API_UNLOCK, assert, dlisth_insert_after, make_debug_h(), malloc_count, MALLOC_HEADER_SZ, mutex, once, and once_function().
int api_check_memory | ( | FILE * | fp | ) |
Definition at line 458 of file api_util.c.
References API_LOCK, api_malloc_dhook_flag_set, API_ONCE_FUNC, API_UNLOCK, dlisth_is_empty, dump_debug_h(), free_count, malloc_count, mutex, dlisth_s::next, once, and once_function().
void api_free | ( | void * | ptr, |
const char * | file, | ||
int | line | ||
) |
Definition at line 431 of file api_util.c.
References API_LOCK, api_malloc_dhook_flag_set, API_ONCE_FUNC, API_UNLOCK, dlisth_delete, free_count, MALLOC_HEADER_SZ, mutex, NULL, once, once_function(), and p.
void* api_malloc | ( | size_t | size, |
const char * | file, | ||
int | line | ||
) |
Definition at line 399 of file api_util.c.
References API_LOCK, api_malloc_dhook_flag_set, API_ONCE_FUNC, API_UNLOCK, assert, dlisth_insert_after, make_debug_h(), malloc_count, MALLOC_HEADER_SZ, mutex, once, and once_function().
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().
|
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().
int hash_delete | ( | hash_table * | ht, |
void * | key, | ||
void ** | relem | ||
) |
Definition at line 318 of file api_util.c.
References API_FREE, assert, hash_table_s::bucket_sz, hash_table_s::buckets, hash_table_s::comparef, dlisth_delete, ht_elem_s::elem, hash_table_s::hashf, ht_elem_s::head, hash_table_s::keyf, dlisth_s::next, NO_ERROR, NULL, and rc.
Referenced by opool_oid_delete(), and sh_delete().
void hash_destroy | ( | hash_table * | ht, |
ht_destroyf | dtor | ||
) |
Definition at line 198 of file api_util.c.
References API_FREE, assert, hash_table_s::bucket_sz, hash_table_s::buckets, dlisth_delete, ht_elem_s::elem, ht_bucket_s::head, i, dlisth_s::next, and NULL.
Referenced by be_create_static_hash(), opool_create(), opool_destroy(), orp_api_destroy(), and sh_destroy().
int hash_insert | ( | hash_table * | ht, |
void * | elem | ||
) |
Definition at line 275 of file api_util.c.
References API_MALLOC, assert, hash_table_s::bucket_sz, hash_table_s::buckets, dlisth_insert_after, ht_elem_s::elem, ER_INTERFACE_NO_MORE_MEMORY, hash_table_s::hashf, ht_elem_s::head, hash_table_s::keyf, NO_ERROR, NULL, and rc.
Referenced by opool_get_object_resultset(), and sh_insert().
int hash_lookup | ( | hash_table * | ht, |
void * | key, | ||
void ** | relem | ||
) |
Definition at line 233 of file api_util.c.
References assert, hash_table_s::bucket_sz, hash_table_s::buckets, hash_table_s::comparef, ht_elem_s::elem, hash_table_s::hashf, ht_elem_s::head, hash_table_s::keyf, dlisth_s::next, NO_ERROR, NULL, and rc.
Referenced by opool_get_object_resultset(), orp_api_get_object_resultset(), orp_oid_delete(), orp_oid_get_classname(), and sh_lookup().
int hash_new | ( | int | bucket_sz, |
ht_hashf | hashf, | ||
ht_keyf | keyf, | ||
ht_comparef | comparef, | ||
hash_table ** | rht | ||
) |
Definition at line 166 of file api_util.c.
References API_MALLOC, assert, hash_table_s::bucket_sz, hash_table_s::buckets, hash_table_s::comparef, dlisth_init, ER_INTERFACE_NO_MORE_MEMORY, hash_table_s::hashf, ht_bucket_s::head, i, hash_table_s::keyf, NO_ERROR, and NULL.
Referenced by api_object_resultset_pool_create(), be_create_static_hash(), and opool_create().
|
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().
|
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().
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().
|
static |
Definition at line 74 of file api_util.c.
Referenced by api_check_memory(), api_free(), css_initialize_list(), and once_function().
|
static |
Definition at line 73 of file api_util.c.
Referenced by api_calloc(), api_check_memory(), api_malloc(), and once_function().
|
static |
Definition at line 75 of file api_util.c.
|
static |
Definition at line 72 of file api_util.c.
Referenced by api_calloc(), api_check_memory(), api_free(), api_malloc(), heap_classrepr_finalize_cache(), heap_classrepr_initialize_cache(), logtb_global_unique_stat_free(), logtb_initialize_global_unique_stats_table(), once_function(), os_send_signal(), session_state::session_state(), session_state_free(), spage_save_head::spage_save_head(), session_state::~session_state(), and spage_save_head::~spage_save_head().
|
static |
Definition at line 76 of file api_util.c.
Referenced by api_calloc(), api_check_memory(), api_free(), and api_malloc().