[Groonga-commit] groonga/groonga at 4d5c24b [master] Reduce scope

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Apr 10 15:48:18 JST 2016


Kouhei Sutou	2016-04-10 15:48:18 +0900 (Sun, 10 Apr 2016)

  New Revision: 4d5c24bc7fe7b8215eac5aa004662c7f0d3c61c4
  https://github.com/groonga/groonga/commit/4d5c24bc7fe7b8215eac5aa004662c7f0d3c61c4

  Message:
    Reduce scope

  Modified files:
    lib/proc/proc_select.c

  Modified: lib/proc/proc_select.c (+14 -8)
===================================================================
--- lib/proc/proc_select.c    2016-04-10 15:45:22 +0900 (5e7697f)
+++ lib/proc/proc_select.c    2016-04-10 15:48:18 +0900 (7acb417)
@@ -540,7 +540,6 @@ grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
   grn_table_group_result *results;
   grn_obj *labels = NULL;
   grn_obj tsorted_ids;
-  tsort_status *visits;
 
   labels = grn_table_create(ctx, NULL, 0, NULL,
                             GRN_OBJ_TABLE_HASH_KEY,
@@ -549,14 +548,22 @@ grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
   if (!labels) {
     return;
   }
-  visits = GRN_PLUGIN_MALLOCN(ctx, tsort_status, n_drilldowns);
 
-  drilldown_info_tsort_init(ctx, labels, visits, drilldowns, n_drilldowns);
   GRN_UINT32_INIT(&tsorted_ids, GRN_OBJ_VECTOR);
-  if (!drilldown_info_tsort(ctx, labels, visits,
-                            drilldowns, n_drilldowns, &tsorted_ids)) {
-    /* cyclic */
-    goto exit;
+
+  {
+    tsort_status *visits;
+    grn_bool succeeded;
+
+    visits = GRN_PLUGIN_MALLOCN(ctx, tsort_status, n_drilldowns);
+    drilldown_info_tsort_init(ctx, labels, visits, drilldowns, n_drilldowns);
+    succeeded = drilldown_info_tsort(ctx, labels, visits,
+                                     drilldowns, n_drilldowns, &tsorted_ids);
+    GRN_PLUGIN_FREE(ctx, visits);
+    if (!succeeded) {
+      /* cyclic */
+      goto exit;
+    }
   }
 
   results = GRN_PLUGIN_MALLOCN(ctx, grn_table_group_result, n_drilldowns);
@@ -674,7 +681,6 @@ grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
   GRN_PLUGIN_FREE(ctx, results);
 
 exit :
-  GRN_PLUGIN_FREE(ctx, visits);
   GRN_OBJ_FIN(ctx, &tsorted_ids);
   grn_obj_unlink(ctx, labels);
 }
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index