41 #if !defined (SERVER_MODE) 44 #if defined (SERVER_MODE) 47 #if defined (SERVER_MODE) 51 #define DEFAULT_OBSTACK_CHUNK_SIZE 32768 53 #if !defined (SERVER_MODE) 58 #if defined (SERVER_MODE) 81 for (; *s == *t; s++, t++)
113 return (*(
unsigned const char *) s < *(
unsigned const char *) t) ? -1 : 1;
136 size_t s_length, t_length, min_length;
142 min_length = s_length < t_length ? s_length : t_length;
153 if (s_length == t_length)
194 if (n >= (
int)
sizeof (
double))
196 return (
int)
sizeof (double);
198 else if (n >= (
int)
sizeof (
void *))
200 return (
int)
sizeof (
void *);
202 else if (n >= (
int)
sizeof (int))
204 return (
int)
sizeof (int);
206 else if (n >= (
int)
sizeof (short))
208 return (
int)
sizeof (short);
230 return (n + alignment - 1) & ~(alignment - 1);
265 if (heap_id && size > 0)
272 #if defined (ENABLE_UNUSED_FUNCTION) 280 db_ostk_free (HL_HEAPID heap_id,
void *ptr)
296 HL_HEAPID heap_id = 0;
297 #if defined (SERVER_MODE) 318 #if defined (SERVER_MODE) 319 heap_id = db_private_get_heapid_from_thread (thread_p);
339 HL_HEAPID old_heap_id;
341 #if defined (SERVER_MODE) 342 old_heap_id = db_private_set_heapid_to_thread (thread_p, heap_id);
361 HL_HEAPID old_heap_id, heap_id;
363 #if defined (SERVER_MODE) 364 old_heap_id = db_private_get_heapid_from_thread (thread_p);
369 #if defined (SERVER_MODE) 371 db_private_set_heapid_to_thread (thread_p, heap_id);
392 #if defined (SERVER_MODE) 393 heap_id = db_private_get_heapid_from_thread (thread_p);
418 db_private_alloc_release (
THREAD_ENTRY * thrd,
size_t size,
bool rc_track)
436 db_private_alloc_release (
THREAD_ENTRY * thrd,
size_t size,
bool rc_track)
439 #if !defined (CS_MODE) 443 #if defined (SERVER_MODE) 449 #if defined (CS_MODE) 451 #elif defined (SERVER_MODE) 457 heap_id = db_private_get_heapid_from_thread (thrd);
472 #if !defined (NDEBUG) 473 if (rc_track && heap_id != 0)
497 PRIVATE_MALLOC_HEADER *h =
NULL;
500 req_sz = private_request_size (size);
505 h->magic = PRIVATE_MALLOC_HEADER_MAGIC;
506 h->alloc_type = PRIVATE_ALLOC_TYPE_LEA;
507 return private_hl2user_ptr (h);
539 db_private_realloc_release (
THREAD_ENTRY * thrd,
void *ptr,
size_t size,
bool rc_track)
559 db_private_realloc_release (
THREAD_ENTRY * thrd,
void *ptr,
size_t size,
bool rc_track)
562 #if !defined (CS_MODE) 563 void *new_ptr =
NULL;
566 #if defined (SERVER_MODE) 570 #if defined (CS_MODE) 572 #elif defined (SERVER_MODE) 578 heap_id = db_private_get_heapid_from_thread (thrd);
586 new_ptr = realloc (ptr, size);
593 #if !defined (NDEBUG) 594 if (rc_track && heap_id != 0 && new_ptr != ptr)
624 PRIVATE_MALLOC_HEADER *h;
626 h = private_user2hl_ptr (ptr);
627 if (h->magic != PRIVATE_MALLOC_HEADER_MAGIC)
632 if (h->alloc_type == PRIVATE_ALLOC_TYPE_LEA)
634 PRIVATE_MALLOC_HEADER *new_h;
637 req_sz = private_request_size (size);
643 return private_hl2user_ptr (new_h);
645 else if (h->alloc_type == PRIVATE_ALLOC_TYPE_WS)
656 new_ptr = realloc (ptr, size);
709 db_private_free_release (
THREAD_ENTRY * thrd,
void *ptr,
bool rc_track)
727 db_private_free_release (
THREAD_ENTRY * thrd,
void *ptr,
bool rc_track)
730 #if defined (SERVER_MODE) 739 #if defined (CS_MODE) 741 #elif defined (SERVER_MODE) 742 heap_id = db_private_get_heapid_from_thread (thrd);
753 #if !defined (NDEBUG) 754 if (rc_track && heap_id != 0)
758 thrd->get_alloc_tracker ().decrement (ptr);
777 PRIVATE_MALLOC_HEADER *h;
779 h = private_user2hl_ptr (ptr);
780 if (h->magic != PRIVATE_MALLOC_HEADER_MAGIC)
786 if (h->alloc_type == PRIVATE_ALLOC_TYPE_LEA)
790 else if (h->alloc_type == PRIVATE_ALLOC_TYPE_WS)
809 return db_private_alloc_release (thrd, size,
false);
820 db_private_free_release (thrd, ptr,
false);
831 return db_private_realloc_release (thrd, ptr, size,
false);
835 #if defined (SERVER_MODE) 843 os_malloc_debug (
size_t size,
bool rc_track,
const char *caller_file,
int caller_line)
846 os_malloc_release (
size_t size,
bool rc_track)
859 #if !defined (NDEBUG) 880 os_calloc_debug (
size_t n,
size_t size,
bool rc_track,
const char *caller_file,
int caller_line)
883 os_calloc_release (
size_t n,
size_t size,
bool rc_track)
890 ptr = calloc (n, size);
896 #if !defined (NDEBUG) 916 os_free_debug (
void *ptr,
bool rc_track,
const char *caller_file,
int caller_line)
919 os_free_release (
void *ptr,
bool rc_track)
924 #if !defined (NDEBUG) 935 #if defined (SERVER_MODE) 944 if (thread_p ==
NULL)
950 return thread_p->private_heap_id;
960 db_private_set_heapid_to_thread (
THREAD_ENTRY * thread_p, HL_HEAPID heap_id)
962 HL_HEAPID old_heap_id = 0;
964 if (thread_p ==
NULL)
971 old_heap_id = thread_p->private_heap_id;
972 thread_p->private_heap_id = heap_id;
976 #endif // SERVER_MODE int intl_identifier_ncasecmp(const char *str1, const char *str2, const int len)
void * db_private_realloc_external(THREAD_ENTRY *thrd, void *ptr, size_t size)
cubthread::entry * thread_get_thread_entry_info(void)
void * hl_lea_realloc(UINTPTR heap_id, void *ptr, size_t sz)
UINTPTR hl_register_lea_heap(void)
void * db_private_alloc_debug(THREAD_ENTRY *thrd, size_t size, bool rc_track, const char *caller_file, int caller_line)
void hl_clear_lea_heap(UINTPTR heap_id)
void hl_unregister_ostk_heap(UINTPTR heap_id)
int ansisql_strcmp(const char *s, const char *t)
void * db_ws_realloc(void *ptr, size_t size)
HL_HEAPID db_change_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
void db_ws_free(void *ptr)
cubbase::alloc_tracker & get_alloc_tracker(void)
void increment(const char *filename, const int line, const res_type &res, unsigned use_count=1)
void db_destroy_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
void * db_ostk_alloc(HL_HEAPID heap_id, size_t size)
void db_clear_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
HL_HEAPID db_create_private_heap(void)
char * db_private_strdup(THREAD_ENTRY *thrd, const char *s)
#define ER_OUT_OF_VIRTUAL_MEMORY
HL_HEAPID private_heap_id
void * db_private_realloc_debug(THREAD_ENTRY *thrd, void *ptr, size_t size, bool rc_track, const char *caller_file, int caller_line)
HL_HEAPID db_create_ostk_heap(int chunk_size)
void db_private_free_external(THREAD_ENTRY *thrd, void *ptr)
void db_private_free_debug(THREAD_ENTRY *thrd, void *ptr, bool rc_track, const char *caller_file, int caller_line)
void hl_unregister_lea_heap(UINTPTR heap_id)
#define db_private_alloc(thrd, size)
unsigned int db_on_server
void hl_ostk_free(UINTPTR heap_id, void *ptr)
void decrement(const res_type &res, unsigned use_count=1)
void * hl_ostk_alloc(UINTPTR heap_id, size_t sz)
void * db_ws_alloc(size_t size)
void * hl_lea_alloc(UINTPTR heap_id, size_t sz)
UINTPTR hl_register_ostk_heap(int chunk_size)
void * db_private_alloc_external(THREAD_ENTRY *thrd, size_t size)
HL_HEAPID db_replace_private_heap(THREAD_ENTRY *thread_p)
void db_destroy_ostk_heap(HL_HEAPID heap_id)
int db_align_to(int n, int alignment)
void hl_lea_free(UINTPTR heap_id, void *ptr)
int ansisql_strcasecmp(const char *s, const char *t)