1
by brian
clean slate |
1 |
/************************************************************************
|
2 |
The memory management: the debug code. This is not an independent
|
|
3 |
compilation module but is included in mem0mem.*.
|
|
4 |
||
5 |
(c) 1994, 1995 Innobase Oy
|
|
6 |
||
7 |
Created 6/8/1994 Heikki Tuuri
|
|
8 |
*************************************************************************/
|
|
9 |
||
10 |
#ifdef UNIV_MEM_DEBUG
|
|
11 |
extern mutex_t mem_hash_mutex; |
|
12 |
extern ulint mem_current_allocated_memory; |
|
13 |
||
14 |
/**********************************************************************
|
|
15 |
Initializes an allocated memory field in the debug version. */
|
|
16 |
||
17 |
void
|
|
18 |
mem_field_init( |
|
19 |
/*===========*/
|
|
20 |
byte* buf, /* in: memory field */ |
|
21 |
ulint n); /* in: how many bytes the user requested */ |
|
22 |
/**********************************************************************
|
|
23 |
Erases an allocated memory field in the debug version. */
|
|
24 |
||
25 |
void
|
|
26 |
mem_field_erase( |
|
27 |
/*============*/
|
|
28 |
byte* buf, /* in: memory field */ |
|
29 |
ulint n); /* in: how many bytes the user requested */ |
|
30 |
/*******************************************************************
|
|
31 |
Initializes a buffer to a random combination of hex BA and BE.
|
|
32 |
Used to initialize allocated memory. */
|
|
33 |
||
34 |
void
|
|
35 |
mem_init_buf( |
|
36 |
/*=========*/
|
|
37 |
byte* buf, /* in: pointer to buffer */ |
|
38 |
ulint n); /* in: length of buffer */ |
|
39 |
/*******************************************************************
|
|
40 |
Initializes a buffer to a random combination of hex DE and AD.
|
|
41 |
Used to erase freed memory.*/
|
|
42 |
||
43 |
void
|
|
44 |
mem_erase_buf( |
|
45 |
/*==========*/
|
|
46 |
byte* buf, /* in: pointer to buffer */ |
|
47 |
ulint n); /* in: length of buffer */ |
|
48 |
/*******************************************************************
|
|
49 |
Inserts a created memory heap to the hash table of
|
|
50 |
current allocated memory heaps.
|
|
51 |
Initializes the hash table when first called. */
|
|
52 |
||
53 |
void
|
|
54 |
mem_hash_insert( |
|
55 |
/*============*/
|
|
56 |
mem_heap_t* heap, /* in: the created heap */ |
|
57 |
const char* file_name, /* in: file name of creation */ |
|
58 |
ulint line); /* in: line where created */ |
|
59 |
/*******************************************************************
|
|
60 |
Removes a memory heap (which is going to be freed by the caller)
|
|
61 |
from the list of live memory heaps. Returns the size of the heap
|
|
62 |
in terms of how much memory in bytes was allocated for the user of
|
|
63 |
the heap (not the total space occupied by the heap).
|
|
64 |
Also validates the heap.
|
|
65 |
NOTE: This function does not free the storage occupied by the
|
|
66 |
heap itself, only the node in the list of heaps. */
|
|
67 |
||
68 |
void
|
|
69 |
mem_hash_remove( |
|
70 |
/*============*/
|
|
71 |
mem_heap_t* heap, /* in: the heap to be freed */ |
|
72 |
const char* file_name, /* in: file name of freeing */ |
|
73 |
ulint line); /* in: line where freed */ |
|
74 |
||
75 |
||
76 |
void
|
|
77 |
mem_field_header_set_len(byte* field, ulint len); |
|
78 |
||
79 |
ulint
|
|
80 |
mem_field_header_get_len(byte* field); |
|
81 |
||
82 |
void
|
|
83 |
mem_field_header_set_check(byte* field, ulint check); |
|
84 |
||
85 |
ulint
|
|
86 |
mem_field_header_get_check(byte* field); |
|
87 |
||
88 |
void
|
|
89 |
mem_field_trailer_set_check(byte* field, ulint check); |
|
90 |
||
91 |
ulint
|
|
92 |
mem_field_trailer_get_check(byte* field); |
|
93 |
#endif /* UNIV_MEM_DEBUG */ |