diff options
Diffstat (limited to 'src/interfaces/ecpg/preproc/ecpg.c')
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 86 |
1 files changed, 21 insertions, 65 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 16bac221f51..ee6e634e456 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -28,7 +28,6 @@ struct _include_path *include_paths = NULL; struct cursor *cur = NULL; struct typedefs *types = NULL; struct _defines *defines = NULL; -struct declared_name_st *g_declared_list = NULL; static void help(const char *progname) @@ -112,48 +111,6 @@ add_preprocessor_define(char *define) defines->next = pd; } -static void -free_argument(struct arguments *arg) -{ - if (arg == NULL) - return; - - free_argument(arg->next); - - /* - * Don't free variables in it because the original codes don't free it - * either variables are static structures instead of allocating - */ - free(arg); -} - -static void -free_cursor(struct cursor *c) -{ - if (c == NULL) - return; - - free_cursor(c->next); - free_argument(c->argsinsert); - free_argument(c->argsresult); - - free(c->name); - free(c->function); - free(c->command); - free(c->prepared_name); - free(c); -} - -static void -free_declared_stmt(struct declared_name_st *st) -{ - if (st == NULL) - return; - - free_declared_stmt(st->next); - free(st); -} - #define ECPG_GETOPT_LONG_REGRESSION 1 int main(int argc, char *const argv[]) @@ -391,18 +348,29 @@ main(int argc, char *const argv[]) struct typedefs *typeptr; /* remove old cursor definitions if any are still there */ - if (cur) + for (ptr = cur; ptr != NULL;) { - free_cursor(cur); - cur = NULL; - } - - /* remove old declared statements if any are still there */ - if (g_declared_list) - { - free_declared_stmt(g_declared_list); - g_declared_list = NULL; + struct cursor *this = ptr; + struct arguments *l1, + *l2; + + free(ptr->command); + free(ptr->connection); + free(ptr->name); + for (l1 = ptr->argsinsert; l1; l1 = l2) + { + l2 = l1->next; + free(l1); + } + for (l1 = ptr->argsresult; l1; l1 = l2) + { + l2 = l1->next; + free(l1); + } + ptr = ptr->next; + free(this); } + cur = NULL; /* remove non-pertinent old defines as well */ while (defines && !defines->pertinent) @@ -519,18 +487,6 @@ main(int argc, char *const argv[]) free(input_filename); } - - if (g_declared_list) - { - free_declared_stmt(g_declared_list); - g_declared_list = NULL; - } - - if (cur) - { - free_cursor(cur); - cur = NULL; - } } return ret_value; } |