1
/*****************************************************************************
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/********************************************************************//**
20
@file include/mem0dbg.ic
1
/************************************************************************
21
2
The memory management: the debug code. This is not an independent
22
3
compilation module but is included in mem0mem.*.
5
(c) 1994, 1995 Innobase Oy
24
7
Created 6/8/1994 Heikki Tuuri
25
8
*************************************************************************/
27
10
#ifdef UNIV_MEM_DEBUG
28
# ifndef UNIV_HOTBACKUP
29
11
extern mutex_t mem_hash_mutex;
30
# endif /* !UNIV_HOTBACKUP */
31
12
extern ulint mem_current_allocated_memory;
33
/******************************************************************//**
14
/**********************************************************************
34
15
Initializes an allocated memory field in the debug version. */
39
byte* buf, /*!< in: memory field */
40
ulint n); /*!< in: how many bytes the user requested */
41
/******************************************************************//**
20
byte* buf, /* in: memory field */
21
ulint n); /* in: how many bytes the user requested */
22
/**********************************************************************
42
23
Erases an allocated memory field in the debug version. */
47
byte* buf, /*!< in: memory field */
48
ulint n); /*!< in: how many bytes the user requested */
49
/***************************************************************//**
28
byte* buf, /* in: memory field */
29
ulint n); /* in: how many bytes the user requested */
30
/*******************************************************************
50
31
Initializes a buffer to a random combination of hex BA and BE.
51
32
Used to initialize allocated memory. */
56
byte* buf, /*!< in: pointer to buffer */
57
ulint n); /*!< in: length of buffer */
58
/***************************************************************//**
37
byte* buf, /* in: pointer to buffer */
38
ulint n); /* in: length of buffer */
39
/*******************************************************************
59
40
Initializes a buffer to a random combination of hex DE and AD.
60
Used to erase freed memory. */
41
Used to erase freed memory.*/
65
byte* buf, /*!< in: pointer to buffer */
66
ulint n); /*!< in: length of buffer */
67
/***************************************************************//**
46
byte* buf, /* in: pointer to buffer */
47
ulint n); /* in: length of buffer */
48
/*******************************************************************
68
49
Inserts a created memory heap to the hash table of
69
50
current allocated memory heaps.
70
51
Initializes the hash table when first called. */
75
mem_heap_t* heap, /*!< in: the created heap */
76
const char* file_name, /*!< in: file name of creation */
77
ulint line); /*!< in: line where created */
78
/***************************************************************//**
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
/*******************************************************************
79
60
Removes a memory heap (which is going to be freed by the caller)
80
61
from the list of live memory heaps. Returns the size of the heap
81
62
in terms of how much memory in bytes was allocated for the user of