[Groonga-commit] groonga/groonga at 0cea831 [master] Support GNR_OBJ_OWN in grn_obj_reinit()

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Tue Sep 8 22:57:02 JST 2015


Kouhei Sutou	2015-09-08 22:57:02 +0900 (Tue, 08 Sep 2015)

  New Revision: 0cea8317909f5b641d09c353e3c14abd7440132c
  https://github.com/groonga/groonga/commit/0cea8317909f5b641d09c353e3c14abd7440132c

  Message:
    Support GNR_OBJ_OWN in grn_obj_reinit()

  Modified files:
    lib/db.c

  Modified: lib/db.c (+24 -0)
===================================================================
--- lib/db.c    2015-09-08 22:56:21 +0900 (07d6768)
+++ lib/db.c    2015-09-08 22:57:02 +0900 (24a0bf3)
@@ -9578,6 +9578,30 @@ grn_obj_reinit(grn_ctx *ctx, grn_obj *obj, grn_id domain, unsigned char flags)
   if (!GRN_OBJ_MUTABLE(obj)) {
     ERR(GRN_INVALID_ARGUMENT, "invalid obj assigned");
   } else {
+    switch (obj->header.type) {
+    case GRN_PTR :
+      if (obj->header.impl_flags & GRN_OBJ_OWN) {
+        if (GRN_BULK_VSIZE(obj) == sizeof(grn_obj *)) {
+          grn_obj_close(ctx, GRN_PTR_VALUE(obj));
+        }
+        obj->header.impl_flags &= ~GRN_OBJ_OWN;
+      }
+      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.impl_flags &= ~GRN_OBJ_OWN;
+      }
+      break;
+    default :
+      break;
+    }
+
     switch (domain) {
     case GRN_DB_VOID :
       if (obj->header.type == GRN_VECTOR) { VECTOR_CLEAR(ctx, obj); }
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る