diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-01-31 09:48:19 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-01-31 09:48:19 +0100 |
commit | ab83952f293ea46c00e421c81b81a394c9cae2b4 (patch) | |
tree | 6a3e995bd1330828a0e988d896bca218863fc74c /include/my_sys.h | |
parent | 055b62f404ee0a0463ee8ff98a0e24c083b95f1d (diff) | |
parent | 5267af5e9e5e601d4f4b1ef40730da1e36d38d9d (diff) | |
download | mariadb-git-ab83952f293ea46c00e421c81b81a394c9cae2b4.tar.gz |
10.0-base merge
Diffstat (limited to 'include/my_sys.h')
-rw-r--r-- | include/my_sys.h | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 30513d17e0a..48459c3fb83 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -86,6 +86,10 @@ typedef struct my_aio_result { #define MY_SYNC 4096 /* my_copy(): sync dst file */ #define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */ #define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */ +#define MY_THREAD_SPECIFIC 0x10000 /* my_malloc(): thread specific */ +#define MY_THREAD_MOVE 0x20000 /* realloc(); Memory can move */ +/* Tree that should delete things automaticly */ +#define MY_TREE_WITH_DELETE 0x40000 #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ @@ -148,6 +152,18 @@ typedef struct my_aio_result { /* Extra length needed for filename if one calls my_create_backup_name */ #define MY_BACKUP_NAME_EXTRA_LENGTH 17 +/* If we have our own safemalloc (for debugging) */ +#if defined(SAFEMALLOC) +void sf_report_leaked_memory(my_thread_id id); +extern my_thread_id (*sf_malloc_dbug_id)(void); +#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) +#else +#define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0) +#endif + +typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific); +extern void set_malloc_size_cb(MALLOC_SIZE_CB func); + /* defines when allocating data */ extern void *my_malloc(size_t Size,myf MyFlags); extern void *my_multi_malloc(myf MyFlags, ...); @@ -183,7 +199,7 @@ extern void my_large_free(uchar *ptr); #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) ((void)0) #else -#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE)) +#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE|MY_THREAD_SPECIFIC)) #define my_afree(PTR) my_free(PTR) #endif /* HAVE_ALLOCA */ @@ -323,6 +339,7 @@ typedef struct st_dynamic_array uint elements,max_element; uint alloc_increment; uint size_of_element; + myf malloc_flags; } DYNAMIC_ARRAY; typedef struct st_my_tmpdir @@ -773,16 +790,10 @@ extern my_bool real_open_cached_file(IO_CACHE *cache); extern void close_cached_file(IO_CACHE *cache); File create_temp_file(char *to, const char *dir, const char *pfx, int mode, myf MyFlags); -#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D) -#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D) -#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) -#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) -extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, +#define my_init_dynamic_array(A,B,C,D,E) my_init_dynamic_array2(A,B,NULL,C,D,E) +extern my_bool my_init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, void *init_buffer, uint init_alloc, - uint alloc_increment); -/* init_dynamic_array() function is deprecated */ -extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, - uint init_alloc, uint alloc_increment); + uint alloc_increment, myf my_flags); extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element); extern void *alloc_dynamic(DYNAMIC_ARRAY *array); extern void *pop_dynamic(DYNAMIC_ARRAY*); @@ -807,12 +818,23 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, size_t length); extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...); +extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str, + const char *append, size_t len, + char quote); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); extern void dynstr_free(DYNAMIC_STRING *str); +extern uint32 copy_and_convert_extended(char *to, uint32 to_length, + CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + CHARSET_INFO *from_cs, uint *errors); extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length, size_t *alloc_length); +extern uint32 copy_and_convert_extended(char *to, uint32 to_length, + CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + CHARSET_INFO *from_cs, uint *errors); #ifdef HAVE_MLOCK extern void *my_malloc_lock(size_t length,myf flags); extern void my_free_lock(void *ptr); @@ -824,7 +846,7 @@ extern void my_free_lock(void *ptr); #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, - size_t pre_alloc_size); + size_t pre_alloc_size, myf my_flags); extern void *alloc_root(MEM_ROOT *mem_root, size_t Size); extern void *multi_alloc_root(MEM_ROOT *mem_root, ...); extern void free_root(MEM_ROOT *root, myf MyFLAGS); |