move variable reset close to definitions
authorMarko Kreen <markokr@gmail.com>
Fri, 6 Jun 2008 11:01:44 +0000 (11:01 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 6 Jun 2008 11:01:44 +0000 (11:01 +0000)
src/parser.y

index 6f8854e8990fa3bd5992a56ca3a7e53a5c4918a4..152867e9e0b34e9e5fe3380445782ba9385d0f16 100644 (file)
@@ -38,8 +38,17 @@ static int got_run, got_cluster, got_connect;
 static QueryBuffer *cluster_sql;
 static QueryBuffer *select_sql;
 static QueryBuffer *hash_sql;
+
+/* points to one of the above ones */
 static QueryBuffer *cur_sql;
 
+/* keep the resetting code together with variables */
+static void reset_parser_vars(void)
+{
+       got_run = got_cluster = got_connect = 0;
+       cur_sql = select_sql = cluster_sql = hash_sql = NULL;
+}
+
 %}
 
 %name-prefix="plproxy_yy"
@@ -148,8 +157,7 @@ void plproxy_run_parser(ProxyFunction *func, const char *body, int len)
        xfunc = func;
 
        /* reset variables, in case there was error exit */
-       got_run = got_cluster = got_connect = 0;
-       cur_sql = select_sql = cluster_sql = hash_sql = NULL;
+       reset_parser_vars();
 
        /* By default expect RUN ON ANY; */
        xfunc->run_type = R_ANY;
@@ -184,6 +192,6 @@ void plproxy_run_parser(ProxyFunction *func, const char *body, int len)
                xfunc->cluster_sql = plproxy_query_finish(cluster_sql);
 
        xfunc = NULL;
-       cur_sql = select_sql = cluster_sql = hash_sql = NULL;
+       reset_parser_vars();
 }