diff options
author | unknown <knielsen@mysql.com> | 2006-05-16 14:34:35 +0200 |
---|---|---|
committer | unknown <knielsen@mysql.com> | 2006-05-16 14:34:35 +0200 |
commit | 771d3d822955e28c58b4384524938ba9162ec5ab (patch) | |
tree | 08fb4ce18ad7defbb710e90b6e9b2c7cccc3eabf /dbug/dbug.c | |
parent | 39b5c0f50dadd8d2018bd4252e9b748a708675dd (diff) | |
parent | a046322b4e61aaef3db9efc9e85477792085c453 (diff) | |
download | mariadb-git-771d3d822955e28c58b4384524938ba9162ec5ab.tar.gz |
Merge mysql.com:/usr/local/mysql/mysql-5.0-vgfix
into mysql.com:/usr/local/mysql/tmp-5.1
client/mysqlbinlog.cc:
Auto merged
include/my_sys.h:
Auto merged
libmysql/libmysql.c:
Auto merged
mysys/my_init.c:
Auto merged
sql/mysqld.cc:
Auto merged
dbug/dbug.c:
Manual merge
include/my_dbug.h:
Manual merge
Diffstat (limited to 'dbug/dbug.c')
-rw-r--r-- | dbug/dbug.c | 78 |
1 files changed, 65 insertions, 13 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index 52de4b4a92d..0c019b5def8 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -255,6 +255,8 @@ static void DBUGOpenFile(CODE_STATE *,const char *, const char *, int); static void DBUGCloseFile(CODE_STATE *cs, FILE *fp); /* Push current debug settings */ static void PushState(CODE_STATE *cs); + /* Free memory associated with debug state. */ +static void FreeState (struct state *state); /* Test for tracing enabled */ static BOOLEAN DoTrace(CODE_STATE *cs); @@ -742,19 +744,7 @@ void _db_pop_() if (discard->next != NULL) { cs->stack= discard->next; - if (!is_shared(discard, keywords)) - FreeList(discard->keywords); - if (!is_shared(discard, functions)) - FreeList(discard->functions); - if (!is_shared(discard, processes)) - FreeList(discard->processes); - if (!is_shared(discard, p_functions)) - FreeList(discard->p_functions); - if (!is_shared(discard, out_file)) - DBUGCloseFile(cs, discard->out_file); - if (discard->prof_file) - DBUGCloseFile(cs, discard->prof_file); - free((char *) discard); + FreeState(discard); } } @@ -1425,6 +1415,68 @@ static void PushState(CODE_STATE *cs) cs->stack= new_malloc; } +/* + * FUNCTION + * + * FreeState Free memory associated with a struct state. + * + * SYNOPSIS + * + * static void FreeState (state) + * struct state *state; + * + * DESCRIPTION + * + * Deallocates the memory allocated for various information in a + * state. + * + */ +static void FreeState ( +struct state *state) +{ + if (!is_shared(state, keywords)) + FreeList(state->keywords); + if (!is_shared(state, functions)) + FreeList(state->functions); + if (!is_shared(state, processes)) + FreeList(state->processes); + if (!is_shared(state, p_functions)) + FreeList(state->p_functions); + if (!is_shared(state, out_file)) + DBUGCloseFile(cs, state->out_file); + if (state->prof_file) + DBUGCloseFile(cs, state->prof_file); + free((char *) state); +} + + +/* + * FUNCTION + * + * _db_end_ End debugging, freeing state stack memory. + * + * SYNOPSIS + * + * static VOID _db_end_ () + * + * DESCRIPTION + * + * Ends debugging, de-allocating the memory allocated to the + * state stack. + * + * To be called at the very end of the program. + * + */ +void _db_end_ () +{ + reg1 struct state *discard; + while((discard= stack) != NULL) { + stack= discard -> next_state; + FreeState (discard); + } + _db_on_=0; +} + /* * FUNCTION |