[Groonga-commit] groonga/groonga at c59463f [master] grn_plugin_proc_get_var: accept -1 for name_size

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 23 11:47:32 JST 2014


Kouhei Sutou	2014-05-23 11:47:32 +0900 (Fri, 23 May 2014)

  New Revision: c59463f645e7c9283d08423eeea5a5a3f3813647
  https://github.com/groonga/groonga/commit/c59463f645e7c9283d08423eeea5a5a3f3813647

  Message:
    grn_plugin_proc_get_var: accept -1 for name_size
    
    If -1 is specified, name_size is computed by strlen(name).
    
    TODO: Document it in doc/source/reference/api/grn_plugin.txt.

  Modified files:
    include/groonga/plugin.h
    lib/plugin.c

  Modified: include/groonga/plugin.h (+5 -2)
===================================================================
--- include/groonga/plugin.h    2014-05-23 11:08:49 +0900 (7c346db)
+++ include/groonga/plugin.h    2014-05-23 11:47:32 +0900 (5bc580a)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2010-2012 Brazil
+  Copyright(C) 2010-2014 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -172,10 +172,13 @@ GRN_API grn_obj *grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
 
 /*
   grn_plugin_proc_get_var() gets a variable from user_data by name.
+
+  If `name_size` is negative, `name` must be
+  NUL-terminated. `name_size` is computed by `strlen(name)` for the case.
 */
 
 GRN_API grn_obj *grn_plugin_proc_get_var(grn_ctx *ctx, grn_user_data *user_data,
-                                         const char *name, unsigned int name_size);
+                                         const char *name, int name_size);
 
 /*
   grn_plugin_proc_get_var_by_offset() gets a variable from user_data by offset.

  Modified: lib/plugin.c (+8 -1)
===================================================================
--- lib/plugin.c    2014-05-23 11:08:49 +0900 (68893cf)
+++ lib/plugin.c    2014-05-23 11:47:32 +0900 (1a2242e)
@@ -637,8 +637,15 @@ grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
 
 grn_obj *
 grn_plugin_proc_get_var(grn_ctx *ctx, grn_user_data *user_data,
-                        const char *name, unsigned int name_size)
+                        const char *name, int name_size)
 {
+  if (name_size < 0) {
+    if (name) {
+      name_size = strlen(name);
+    } else {
+      name_size = 0;
+    }
+  }
   return grn_proc_get_var(ctx, user_data, name, name_size);
 }
 
-------------- next part --------------
HTML����������������������������...
下載 



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