| 1 | /* Copyright (C) 2012-2014 Kentoku Shiba | 
|---|
| 2 |  | 
|---|
| 3 | This program is free software; you can redistribute it and/or modify | 
|---|
| 4 | it under the terms of the GNU General Public License as published by | 
|---|
| 5 | the Free Software Foundation; version 2 of the License. | 
|---|
| 6 |  | 
|---|
| 7 | This program is distributed in the hope that it will be useful, | 
|---|
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 10 | GNU General Public License for more details. | 
|---|
| 11 |  | 
|---|
| 12 | You should have received a copy of the GNU General Public License | 
|---|
| 13 | along with this program; if not, write to the Free Software | 
|---|
| 14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */ | 
|---|
| 15 |  | 
|---|
| 16 | #define spider_free(A,B,C) spider_free_mem(A,B,C) | 
|---|
| 17 | #define spider_malloc(A,B,C,D) \ | 
|---|
| 18 | spider_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,D) | 
|---|
| 19 | #define spider_bulk_malloc(A,B,C,...) \ | 
|---|
| 20 | spider_bulk_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,__VA_ARGS__) | 
|---|
| 21 | #define spider_current_trx \ | 
|---|
| 22 | (current_thd ? ((SPIDER_TRX *) thd_get_ha_data(current_thd, spider_hton_ptr)) : NULL) | 
|---|
| 23 |  | 
|---|
| 24 | #define init_calc_mem(A) init_mem_calc(A,__func__,__FILE__,__LINE__) | 
|---|
| 25 |  | 
|---|
| 26 | #define SPIDER_CALC_MEM_ID(name) name ## _id | 
|---|
| 27 | #define SPIDER_CALC_MEM_FUNC(name) name ## _func_name | 
|---|
| 28 | #define SPIDER_CALC_MEM_FILE(name) name ## _file_name | 
|---|
| 29 | #define SPIDER_CALC_MEM_LINE(name) name ## _line_no | 
|---|
| 30 | #define spider_alloc_calc_mem_init(A,B) \ | 
|---|
| 31 | {SPIDER_CALC_MEM_ID(A) = B; SPIDER_CALC_MEM_FUNC(A) = __func__; SPIDER_CALC_MEM_FILE(A) = __FILE__; SPIDER_CALC_MEM_LINE(A) = __LINE__;} | 
|---|
| 32 | #define spider_alloc_calc_mem(A,B,C) \ | 
|---|
| 33 | spider_alloc_mem_calc(A,SPIDER_CALC_MEM_ID(B),SPIDER_CALC_MEM_FUNC(B),SPIDER_CALC_MEM_FILE(B),SPIDER_CALC_MEM_LINE(B),C) | 
|---|
| 34 |  | 
|---|
| 35 | void spider_merge_mem_calc( | 
|---|
| 36 | SPIDER_TRX *trx, | 
|---|
| 37 | bool force | 
|---|
| 38 | ); | 
|---|
| 39 |  | 
|---|
| 40 | void spider_free_mem_calc( | 
|---|
| 41 | SPIDER_TRX *trx, | 
|---|
| 42 | uint id, | 
|---|
| 43 | size_t size | 
|---|
| 44 | ); | 
|---|
| 45 |  | 
|---|
| 46 | void spider_alloc_mem_calc( | 
|---|
| 47 | SPIDER_TRX *trx, | 
|---|
| 48 | uint id, | 
|---|
| 49 | const char *func_name, | 
|---|
| 50 | const char *file_name, | 
|---|
| 51 | ulong line_no, | 
|---|
| 52 | size_t size | 
|---|
| 53 | ); | 
|---|
| 54 |  | 
|---|
| 55 | void spider_free_mem( | 
|---|
| 56 | SPIDER_TRX *trx, | 
|---|
| 57 | void *ptr, | 
|---|
| 58 | myf my_flags | 
|---|
| 59 | ); | 
|---|
| 60 |  | 
|---|
| 61 | void *spider_alloc_mem( | 
|---|
| 62 | SPIDER_TRX *trx, | 
|---|
| 63 | uint id, | 
|---|
| 64 | const char *func_name, | 
|---|
| 65 | const char *file_name, | 
|---|
| 66 | ulong line_no, | 
|---|
| 67 | size_t size, | 
|---|
| 68 | myf my_flags | 
|---|
| 69 | ); | 
|---|
| 70 |  | 
|---|
| 71 | void *spider_bulk_alloc_mem( | 
|---|
| 72 | SPIDER_TRX *trx, | 
|---|
| 73 | uint id, | 
|---|
| 74 | const char *func_name, | 
|---|
| 75 | const char *file_name, | 
|---|
| 76 | ulong line_no, | 
|---|
| 77 | myf my_flags, | 
|---|
| 78 | ... | 
|---|
| 79 | ); | 
|---|
| 80 |  | 
|---|