diff options
author | knielsen@mysql.com <> | 2006-05-16 14:34:35 +0200 |
---|---|---|
committer | knielsen@mysql.com <> | 2006-05-16 14:34:35 +0200 |
commit | a729d7fcdd8c8458bb0a211923521be9eda9f694 (patch) | |
tree | 08fb4ce18ad7defbb710e90b6e9b2c7cccc3eabf /dbug | |
parent | 2abf957c911e658e0eed202c34bb0b6b915bc79a (diff) | |
parent | fc16aff7423eff1eb52fcd2522b3454fa8748c70 (diff) | |
download | mariadb-git-a729d7fcdd8c8458bb0a211923521be9eda9f694.tar.gz |
Merge mysql.com:/usr/local/mysql/mysql-5.0-vgfix
into mysql.com:/usr/local/mysql/tmp-5.1
Diffstat (limited to 'dbug')
-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 |