Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8675a273
Commit
8675a273
authored
Apr 03, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make safemalloc work without threads
parent
6a5c6b17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
mysys/my_static.h
mysys/my_static.h
+5
-1
mysys/safemalloc.c
mysys/safemalloc.c
+22
-10
No files found.
mysys/my_static.h
View file @
8675a273
...
@@ -38,7 +38,9 @@ struct irem {
...
@@ -38,7 +38,9 @@ struct irem {
my_string
_sFileName
;
/* File in which memory was new'ed */
my_string
_sFileName
;
/* File in which memory was new'ed */
uint
_uLineNum
;
/* Line number in above file */
uint
_uLineNum
;
/* Line number in above file */
uint
_uDataSize
;
/* Size requested */
uint
_uDataSize
;
/* Size requested */
#ifdef THREAD
pthread_t
thread_id
;
pthread_t
thread_id
;
#endif
long
_lSpecialValue
;
/* Underrun marker value */
long
_lSpecialValue
;
/* Underrun marker value */
};
};
...
@@ -57,11 +59,13 @@ extern const char *soundex_map;
...
@@ -57,11 +59,13 @@ extern const char *soundex_map;
extern
USED_MEM
*
my_once_root_block
;
extern
USED_MEM
*
my_once_root_block
;
extern
uint
my_once_extra
;
extern
uint
my_once_extra
;
#ifdef THREAD
/*
/*
These threads are exept from safemalloc leak scrutiny unless
These threads are ex
c
ept from safemalloc leak scrutiny unless
PEDANTIC_SAFEMALLOC is defined
PEDANTIC_SAFEMALLOC is defined
*/
*/
extern
pthread_t
signal_thread
,
kill_thread
;
extern
pthread_t
signal_thread
,
kill_thread
;
#endif
#ifndef HAVE_TEMPNAM
#ifndef HAVE_TEMPNAM
extern
int
_my_tempnam_used
;
extern
int
_my_tempnam_used
;
...
...
mysys/safemalloc.c
View file @
8675a273
...
@@ -185,7 +185,9 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
...
@@ -185,7 +185,9 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
pTmp
->
sFileName
=
(
my_string
)
sFile
;
pTmp
->
sFileName
=
(
my_string
)
sFile
;
pTmp
->
uLineNum
=
uLine
;
pTmp
->
uLineNum
=
uLine
;
pTmp
->
uDataSize
=
uSize
;
pTmp
->
uDataSize
=
uSize
;
#ifdef THREAD
pTmp
->
thread_id
=
pthread_self
();
pTmp
->
thread_id
=
pthread_self
();
#endif
pTmp
->
pPrev
=
NULL
;
pTmp
->
pPrev
=
NULL
;
/* Add this remember structure to the linked list */
/* Add this remember structure to the linked list */
...
@@ -371,12 +373,19 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
...
@@ -371,12 +373,19 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
return
0
;
return
0
;
}
}
#ifdef THREAD
static
int
legal_leak
(
struct
remember
*
pPtr
)
static
int
legal_leak
(
struct
remember
*
pPtr
)
{
{
return
pthread_self
()
==
pPtr
->
thread_id
||
main_th
==
pPtr
->
thread_id
return
pthread_self
()
==
pPtr
->
thread_id
||
main_th
==
pPtr
->
thread_id
||
shutdown_th
==
pPtr
->
thread_id
||
shutdown_th
==
pPtr
->
thread_id
||
signal_th
==
pPtr
->
thread_id
;
||
signal_th
==
pPtr
->
thread_id
;
}
}
#else
static
int
legal_leak
(
struct
remember
*
pPtr
)
{
return
1
;
}
#endif
/*
/*
* TERMINATE(FILE *file)
* TERMINATE(FILE *file)
...
@@ -390,17 +399,20 @@ void TERMINATE (FILE *file)
...
@@ -390,17 +399,20 @@ void TERMINATE (FILE *file)
DBUG_ENTER
(
"TERMINATE"
);
DBUG_ENTER
(
"TERMINATE"
);
pthread_mutex_lock
(
&
THR_LOCK_malloc
);
pthread_mutex_lock
(
&
THR_LOCK_malloc
);
/* Report the difference between number of calls to */
/*
/* NEW and the number of calls to FREE. >0 means more */
Report the difference between number of calls to
/* NEWs than FREEs. <0, etc. */
NEW and the number of calls to FREE. >0 means more
NEWs than FREEs. <0, etc.
*/
#ifndef PEDANTIC_SAFEMALLOC
#if !defined(PEDANTIC_SAFEMALLOC) && defined(THREAD)
/* Avoid false alarms for blocks that we cannot free before my_end()
/*
This does miss some positives, but that is ok. This will only miss
Avoid false alarms for blocks that we cannot free before my_end()
failures to free things allocated in the main thread which
This does miss some positives, but that is ok. This will only miss
performs only one-time allocations. If you really need to
failures to free things allocated in the main thread which
debug memory allocations in the main thread,
performs only one-time allocations. If you really need to
#define PEDANTIC_SAFEMALLOC
debug memory allocations in the main thread,
#define PEDANTIC_SAFEMALLOC
*/
*/
if
((
pPtr
=
pRememberRoot
))
if
((
pPtr
=
pRememberRoot
))
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment