1
/* Copyright (C) 2003 MySQL AB
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.
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.
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 */
16
#include <ndb_global.h>
17
#include "ndbd_malloc.hpp"
20
//#define TRACE_MALLOC
26
static void xxx(size_t size, size_t *s_m, size_t *s_k, size_t *s_b)
28
*s_m = size/1024/1024;
29
*s_k = (size - *s_m*1024*1024)/1024;
30
*s_b = size - *s_m*1024*1024-*s_k*1024;
34
static Uint64 g_allocated_memory;
35
void *ndbd_malloc(size_t size)
37
void *p = NdbMem_Allocate(size);
40
g_allocated_memory += size;
44
xxx(size, &s_m, &s_k, &s_b);
45
fprintf(stderr, "%p malloc(%um %uk %ub)", p, s_m, s_k, s_b);
46
xxx(g_allocated_memory, &s_m, &s_k, &s_b);
47
fprintf(stderr, "\t\ttotal(%um %uk %ub)\n", s_m, s_k, s_b);
54
void ndbd_free(void *p, size_t size)
59
g_allocated_memory -= size;
61
fprintf(stderr, "%p free(%d)\n", p, size);