[Groonga-commit] groonga/groonga at 7bb4f6e [master] grn_expr: dynamically resize expr->codes

Back to archive index

Susumu Yata null+****@clear*****
Tue Dec 8 23:16:43 JST 2015


Susumu Yata	2015-12-08 23:16:43 +0900 (Tue, 08 Dec 2015)

  New Revision: 7bb4f6eb7aed9bb68c003b3c283505bc3444d16c
  https://github.com/groonga/groonga/commit/7bb4f6eb7aed9bb68c003b3c283505bc3444d16c

  Message:
    grn_expr: dynamically resize expr->codes
    
    GitHub: #443

  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+9 -2)
===================================================================
--- lib/expr.c    2015-12-08 11:14:58 +0900 (b97cff5)
+++ lib/expr.c    2015-12-08 23:16:43 +0900 (a4bbca0)
@@ -738,8 +738,15 @@ grn_expr_append_obj(grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op,
   grn_expr *e = (grn_expr *)expr;
   GRN_API_ENTER;
   if (e->codes_curr >= e->codes_size) {
-    ERR(GRN_NO_MEMORY_AVAILABLE, "stack is full");
-    goto exit;
+    uint32_t new_codes_size = e->codes_size * 2;
+    size_t n_bytes = sizeof(grn_expr_code) * new_codes_size;
+    grn_expr_code *new_codes = (grn_expr_code *)GRN_REALLOC(e->codes, n_bytes);
+    if (!new_codes) {
+	    ERR(GRN_NO_MEMORY_AVAILABLE, "stack is full");
+	    goto exit;
+    }
+    e->codes = new_codes;
+    e->codes_size = new_codes_size;
   }
   {
     switch (op) {
-------------- next part --------------
HTML����������������������������...
Download 



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