[Groonga-commit] groonga/groonga at 9059acb [master] ii: use the specified value instead of constant

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 22 17:25:33 JST 2016


Kouhei Sutou	2016-06-22 17:25:33 +0900 (Wed, 22 Jun 2016)

  New Revision: 9059acb07e4a183afe41d5be399129d9c95f81b8
  https://github.com/groonga/groonga/commit/9059acb07e4a183afe41d5be399129d9c95f81b8

  Message:
    ii: use the specified value instead of constant

  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+9 -3)
===================================================================
--- lib/ii.c    2016-06-22 11:25:01 +0900 (ce09f96)
+++ lib/ii.c    2016-06-22 17:25:33 +0900 (017e876)
@@ -338,6 +338,10 @@ static int free_histogram[32];
 static grn_rc
 chunk_new(grn_ctx *ctx, grn_ii *ii, uint32_t *res, uint32_t size)
 {
+  uint32_t n_chunks;
+
+  n_chunks = ii->chunk->header->max_segment;
+
   /*
   if (size) {
     int m, es = size - 1;
@@ -349,7 +353,7 @@ chunk_new(grn_ctx *ctx, grn_ii *ii, uint32_t *res, uint32_t size)
   if (size > S_CHUNK) {
     int i, j;
     uint32_t n = (size + S_CHUNK - 1) >> GRN_II_W_CHUNK;
-    for (i = 0, j = -1; i < GRN_II_MAX_CHUNK; i++) {
+    for (i = 0, j = -1; i < n_chunks; i++) {
       if (HEADER_CHUNK_AT(ii, i)) {
         j = i;
       } else {
@@ -410,7 +414,7 @@ chunk_new(grn_ctx *ctx, grn_ii *ii, uint32_t *res, uint32_t size)
     if (*vp == NOT_ASSIGNED) {
       int i = 0;
       while (HEADER_CHUNK_AT(ii, i)) {
-        if (++i >= GRN_II_MAX_CHUNK) { return GRN_NO_MEMORY_AVAILABLE; }
+        if (++i >= n_chunks) { return GRN_NO_MEMORY_AVAILABLE; }
       }
       HEADER_CHUNK_ON(ii, i);
       *vp = i << GRN_II_N_CHUNK_VARIATION;
@@ -476,7 +480,9 @@ chunk_free(grn_ctx *ctx, grn_ii *ii,
     /*
     uint32_t i = 0;
     while (HEADER_CHUNK_AT(ii, i)) {
-      if (++i >= GRN_II_MAX_CHUNK) { return GRN_NO_MEMORY_AVAILABLE; }
+      if (++i >= ii->chunk->header->max_segment) {
+        return GRN_NO_MEMORY_AVAILABLE;
+      }
     }
     HEADER_CHUNK_ON(ii, i);
     *gseg = i;
-------------- next part --------------
HTML����������������������������...
下載 



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