Ecpglib stores variables that are used in DECLARE statements in a global list.
authorMichael Meskes
Thu, 5 Jan 2012 13:08:45 +0000 (14:08 +0100)
committerMichael Meskes
Thu, 5 Jan 2012 13:08:45 +0000 (14:08 +0100)
This list is now freed when the last connection has been closed.

Closes: #6366
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/misc.c

index 997046b38b73a2c535135c2971ba6b9d46b5278d..909ba700920e5ce5175dc55d8e6c6fbe58596ad7 100644 (file)
@@ -149,6 +149,13 @@ ecpg_finish(struct connection * act)
        for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ecpg_free(ptr));
        ecpg_free(act->name);
        ecpg_free(act);
+       /* delete cursor variables when last connection gets closed */
+       if (all_connections == NULL)
+       {
+           struct var_list *iv_ptr;
+
+           for (; ivlist; iv_ptr = ivlist, ivlist = ivlist->next, ecpg_free(iv_ptr));
+       }
    }
    else
        ecpg_log("ecpg_finish: called an extra time\n");
index 96d49a4a6b752b0c51f479c2eb95088d704bd8b2..bd1ffb096c0a09b287fd4f6c3aa4cd087e4d0d4e 100644 (file)
@@ -121,6 +121,15 @@ struct variable
    struct variable *next;
 };
 
+struct var_list
+{
+   int number;
+   void   *pointer;
+   struct var_list *next;
+};
+
+extern struct var_list *ivlist;
+
 /* Here are some methods used by the lib. */
 
 /* Returns a pointer to a string containing a simple type name. */
index 98e0597b03c8bd7d569a3ebf84ccc0629e956413..f24478271cd618391897768eab672e653d1656cd 100644 (file)
@@ -501,12 +501,7 @@ ecpg_gettext(const char *msgid)
 }
 #endif   /* ENABLE_NLS */
 
-static struct var_list
-{
-   int         number;
-   void       *pointer;
-   struct var_list *next;
-}  *ivlist = NULL;
+struct var_list *ivlist = NULL;
 
 void
 ECPGset_var(int number, void *pointer, int lineno)