[Groonga-commit] groonga/groonga at 886ae93 [master] Add grn_pvector_fin

Back to archive index

Susumu Yata null+****@clear*****
Thu Mar 31 18:12:39 JST 2016


Susumu Yata	2016-03-31 18:12:39 +0900 (Thu, 31 Mar 2016)

  New Revision: 886ae931e0a559565485785f424c76886022da02
  https://github.com/groonga/groonga/commit/886ae931e0a559565485785f424c76886022da02

  Message:
    Add grn_pvector_fin
    
    GitHub: #514

  Modified files:
    lib/db.c
    lib/grn_db.h

  Modified: lib/db.c (+25 -11)
===================================================================
--- lib/db.c    2016-03-31 14:42:26 +0900 (0482899)
+++ lib/db.c    2016-03-31 18:12:39 +0900 (0ddbbe6)
@@ -9863,6 +9863,30 @@ grn_obj_graft(grn_ctx *ctx, grn_obj *obj)
 }
 
 grn_rc
+grn_pvector_fin(grn_ctx *ctx, grn_obj *obj)
+{
+  grn_rc rc;
+  if (obj->header.impl_flags & GRN_OBJ_OWN) {
+    /*
+     * Note that GRN_OBJ_OWN should not be used outside the DB API function
+     * because grn_obj_close is a DB API function.
+     */
+    unsigned int i, n_elements;
+    n_elements = GRN_BULK_VSIZE(obj) / sizeof(grn_obj *);
+    for (i = 0; i < n_elements; i++) {
+      grn_obj *element = GRN_PTR_VALUE_AT(obj, i);
+      grn_obj_close(ctx, element);
+    }
+  }
+  obj->header.type = GRN_VOID;
+  rc = grn_bulk_fin(ctx, obj);
+  if (obj->header.impl_flags & GRN_OBJ_ALLOCATED) {
+    GRN_FREE(obj);
+  }
+  return rc;
+}
+
+grn_rc
 grn_obj_close(grn_ctx *ctx, grn_obj *obj)
 {
   grn_rc rc = GRN_INVALID_ARGUMENT;
@@ -9909,17 +9933,7 @@ grn_obj_close(grn_ctx *ctx, grn_obj *obj)
       if (obj->header.impl_flags & GRN_OBJ_ALLOCATED) { GRN_FREE(obj); }
       break;
     case GRN_PVECTOR :
-      if (obj->header.impl_flags & GRN_OBJ_OWN) {
-        unsigned int i, n_elements;
-        n_elements = GRN_BULK_VSIZE(obj) / sizeof(grn_obj *);
-        for (i = 0; i < n_elements; i++) {
-          grn_obj *element = GRN_PTR_VALUE_AT(obj, i);
-          grn_obj_close(ctx, element);
-        }
-      }
-      obj->header.type = GRN_VOID;
-      rc = grn_bulk_fin(ctx, obj);
-      if (obj->header.impl_flags & GRN_OBJ_ALLOCATED) { GRN_FREE(obj); }
+      rc = grn_pvector_fin(ctx, obj);
       break;
     case GRN_ACCESSOR :
       {

  Modified: lib/grn_db.h (+2 -0)
===================================================================
--- lib/grn_db.h    2016-03-31 14:42:26 +0900 (cc8e2cd)
+++ lib/grn_db.h    2016-03-31 18:12:39 +0900 (e9799fd)
@@ -448,6 +448,8 @@ grn_obj *grn_obj_default_set_value_hook(grn_ctx *ctx,
 
 void grn_obj_touch(grn_ctx *ctx, grn_obj *obj, grn_timeval *tv);
 
+grn_rc grn_pvector_fin(grn_ctx *ctx, grn_obj *obj);
+
 #ifdef __cplusplus
 }
 #endif
-------------- next part --------------
HTML����������������������������...
下载 



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