Skip to content

Commit e3e4013

Browse files
committed
Added memory allocated by my_once_malloc() to global_memory_used
1 parent 2ccf6a2 commit e3e4013

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

mysys/my_once.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ void* my_once_alloc(size_t Size, myf MyFlags)
6363
return((uchar*) 0);
6464
}
6565
DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size));
66+
my_once_allocated+= get_size;
67+
update_malloc_size(get_size, 0);
6668
next->next= 0;
6769
next->size= get_size;
6870
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
@@ -113,7 +115,9 @@ void my_once_free(void)
113115
old=next; next= next->next ;
114116
free((uchar*) old);
115117
}
118+
update_malloc_size(- (longlong) my_once_allocated, 0);
116119
my_once_root_block=0;
120+
my_once_allocated= 0;
117121

118122
DBUG_VOID_RETURN;
119123
} /* my_once_free */

mysys/my_static.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const char *soundex_map= "01230120022455012623010202";
9494
/* from my_malloc */
9595
USED_MEM* my_once_root_block=0; /* pointer to first block */
9696
uint my_once_extra=ONCE_ALLOC_INIT; /* Memory to alloc / block */
97+
size_t my_once_allocated= 0;
9798

9899
/* from my_alarm */
99100
int volatile my_have_got_alarm=0; /* declare variable to reset */

mysys/my_static.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern const char *soundex_map;
4040

4141
extern USED_MEM* my_once_root_block;
4242
extern uint my_once_extra;
43+
extern size_t my_once_allocated;
4344

4445
extern struct st_my_file_info my_file_info_default[MY_NFILE];
4546

0 commit comments

Comments
 (0)