[Groonga-commit] groonga/groonga [master] add const to void *value of *_set_value().

Back to archive index

null+****@clear***** null+****@clear*****
2012年 1月 10日 (火) 16:22:12 JST


Kouhei Sutou	2012-01-10 16:22:12 +0900 (Tue, 10 Jan 2012)

  New Revision: 95678a244a8fed4b2a7a5ef5bb604f251414fd0f

  Log:
    add const to void *value of *_set_value().

  Modified files:
    include/groonga.h
    lib/db.c
    lib/hash.c
    lib/pat.c
    test/unit/core/test-command-dump.c
    test/unit/core/test-command-load.c
    test/unit/core/test-hash.c
    test/unit/core/test-inverted-index.c
    test/unit/core/test-patricia-trie-search.c
    test/unit/core/test-patricia-trie.c
    test/unit/core/test-table.c

  Modified: include/groonga.h (+8 -8)
===================================================================
--- include/groonga.h    2012-01-10 15:59:59 +0900 (f816a25)
+++ include/groonga.h    2012-01-10 16:22:12 +0900 (01316a0)
@@ -957,7 +957,7 @@ GRN_API int grn_table_cursor_get_value(grn_ctx *ctx, grn_table_cursor *tc, void
  * cursorのカレントレコードが存在しない場合はGRN_INVALID_ARGUMENTを返す。
  **/
 GRN_API grn_rc grn_table_cursor_set_value(grn_ctx *ctx, grn_table_cursor *tc,
-                                  void *value, int flags);
+                                          const void *value, int flags);
 
 /**
  * grn_table_cursor_delete:
@@ -2564,8 +2564,8 @@ GRN_API grn_id grn_hash_get(grn_ctx *ctx, grn_hash *hash, const void *key,
 GRN_API int grn_hash_get_key(grn_ctx *ctx, grn_hash *hash, grn_id id, void *keybuf, int bufsize);
 GRN_API int grn_hash_get_key2(grn_ctx *ctx, grn_hash *hash, grn_id id, grn_obj *bulk);
 GRN_API int grn_hash_get_value(grn_ctx *ctx, grn_hash *hash, grn_id id, void *valuebuf);
-GRN_API grn_rc grn_hash_set_value(grn_ctx *ctx, grn_hash *hash, grn_id id, void *value,
-                                  int flags);
+GRN_API grn_rc grn_hash_set_value(grn_ctx *ctx, grn_hash *hash, grn_id id,
+                                  const void *value, int flags);
 
 typedef struct _grn_table_delete_optarg grn_table_delete_optarg;
 
@@ -2591,7 +2591,7 @@ GRN_API void grn_hash_cursor_close(grn_ctx *ctx, grn_hash_cursor *c);
 GRN_API int grn_hash_cursor_get_key(grn_ctx *ctx, grn_hash_cursor *c, void **key);
 GRN_API int grn_hash_cursor_get_value(grn_ctx *ctx, grn_hash_cursor *c, void **value);
 GRN_API grn_rc grn_hash_cursor_set_value(grn_ctx *ctx, grn_hash_cursor *c,
-                                         void *value, int flags);
+                                         const void *value, int flags);
 
 GRN_API int grn_hash_cursor_get_key_value(grn_ctx *ctx, grn_hash_cursor *c,
                                           void **key, unsigned int *key_size, void **value);
@@ -2624,14 +2624,14 @@ GRN_API grn_rc grn_array_close(grn_ctx *ctx, grn_array *array);
 GRN_API grn_id grn_array_add(grn_ctx *ctx, grn_array *array, void **value);
 GRN_API int grn_array_get_value(grn_ctx *ctx, grn_array *array, grn_id id, void *valuebuf);
 GRN_API grn_rc grn_array_set_value(grn_ctx *ctx, grn_array *array, grn_id id,
-                                   void *value, int flags);
+                                   const void *value, int flags);
 GRN_API grn_array_cursor *grn_array_cursor_open(grn_ctx *ctx, grn_array *array,
                                                 grn_id min, grn_id max,
                                                 int offset, int limit, int flags);
 GRN_API grn_id grn_array_cursor_next(grn_ctx *ctx, grn_array_cursor *c);
 GRN_API int grn_array_cursor_get_value(grn_ctx *ctx, grn_array_cursor *c, void **value);
 GRN_API grn_rc grn_array_cursor_set_value(grn_ctx *ctx, grn_array_cursor *c,
-                                          void *value, int flags);
+                                          const void *value, int flags);
 GRN_API grn_rc grn_array_cursor_delete(grn_ctx *ctx, grn_array_cursor *c,
                                        grn_table_delete_optarg *optarg);
 GRN_API void grn_array_cursor_close(grn_ctx *ctx, grn_array_cursor *c);
@@ -2677,7 +2677,7 @@ GRN_API int grn_pat_get_key(grn_ctx *ctx, grn_pat *pat, grn_id id, void *keybuf,
 GRN_API int grn_pat_get_key2(grn_ctx *ctx, grn_pat *pat, grn_id id, grn_obj *bulk);
 GRN_API int grn_pat_get_value(grn_ctx *ctx, grn_pat *pat, grn_id id, void *valuebuf);
 GRN_API grn_rc grn_pat_set_value(grn_ctx *ctx, grn_pat *pat, grn_id id,
-                                 void *value, int flags);
+                                 const void *value, int flags);
 
 GRN_API grn_rc grn_pat_delete_by_id(grn_ctx *ctx, grn_pat *pat, grn_id id,
                                     grn_table_delete_optarg *optarg);
@@ -2719,7 +2719,7 @@ GRN_API int grn_pat_cursor_get_value(grn_ctx *ctx, grn_pat_cursor *c, void **val
 GRN_API int grn_pat_cursor_get_key_value(grn_ctx *ctx, grn_pat_cursor *c,
                                          void **key, unsigned int *key_size, void **value);
 GRN_API grn_rc grn_pat_cursor_set_value(grn_ctx *ctx, grn_pat_cursor *c,
-                                        void *value, int flags);
+                                        const void *value, int flags);
 GRN_API grn_rc grn_pat_cursor_delete(grn_ctx *ctx, grn_pat_cursor *c,
                                      grn_table_delete_optarg *optarg);
 

  Modified: lib/db.c (+1 -1)
===================================================================
--- lib/db.c    2012-01-10 15:59:59 +0900 (eb36bc4)
+++ lib/db.c    2012-01-10 16:22:12 +0900 (57e3af4)
@@ -2477,7 +2477,7 @@ grn_table_cursor_get_value(grn_ctx *ctx, grn_table_cursor *tc, void **value)
 
 grn_rc
 grn_table_cursor_set_value(grn_ctx *ctx, grn_table_cursor *tc,
-                           void *value, int flags)
+                           const void *value, int flags)
 {
   grn_rc rc = GRN_INVALID_ARGUMENT;
   GRN_API_ENTER;

  Modified: lib/hash.c (+10 -5)
===================================================================
--- lib/hash.c    2012-01-10 15:59:59 +0900 (24d24e9)
+++ lib/hash.c    2012-01-10 16:22:12 +0900 (5471026)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -337,7 +338,8 @@ _grn_array_get_value(grn_ctx *ctx, grn_array *array, grn_id id)
 }
 
 grn_rc
-grn_array_set_value(grn_ctx *ctx, grn_array *array, grn_id id, void *value, int flags)
+grn_array_set_value(grn_ctx *ctx, grn_array *array, grn_id id,
+                    const void *value, int flags)
 {
   if (ctx && array && value) {
     void *ee;
@@ -554,7 +556,8 @@ grn_array_cursor_get_value(grn_ctx *ctx, grn_array_cursor *c, void **value)
 }
 
 grn_rc
-grn_array_cursor_set_value(grn_ctx *ctx, grn_array_cursor *c, void *value, int flags)
+grn_array_cursor_set_value(grn_ctx *ctx, grn_array_cursor *c,
+                           const void *value, int flags)
 {
   return grn_array_set_value(ctx, c->array, c->curr_rec, value, flags);
 }
@@ -1446,7 +1449,8 @@ _grn_hash_get_key_value(grn_ctx *ctx, grn_hash *hash, grn_id id,
 }
 
 grn_rc
-grn_hash_set_value(grn_ctx *ctx, grn_hash *hash, grn_id id, void *value, int flags)
+grn_hash_set_value(grn_ctx *ctx, grn_hash *hash, grn_id id,
+                   const void *value, int flags)
 {
   if (value) {
     void *v;
@@ -1756,7 +1760,8 @@ grn_hash_cursor_get_key_value(grn_ctx *ctx, grn_hash_cursor *c,
 }
 
 grn_rc
-grn_hash_cursor_set_value(grn_ctx *ctx, grn_hash_cursor *c, void *value, int flags)
+grn_hash_cursor_set_value(grn_ctx *ctx, grn_hash_cursor *c,
+                          const void *value, int flags)
 {
   if (!c) { return GRN_INVALID_ARGUMENT; }
   return grn_hash_set_value(ctx, c->hash, c->curr_rec, value, flags);

  Modified: lib/pat.c (+4 -2)
===================================================================
--- lib/pat.c    2012-01-10 15:59:59 +0900 (6d584b3)
+++ lib/pat.c    2012-01-10 16:22:12 +0900 (19d5c92)
@@ -1281,7 +1281,8 @@ grn_pat_get_value_(grn_ctx *ctx, grn_pat *pat, grn_id id, uint32_t *size)
 }
 
 grn_rc
-grn_pat_set_value(grn_ctx *ctx, grn_pat *pat, grn_id id, void *value, int flags)
+grn_pat_set_value(grn_ctx *ctx, grn_pat *pat, grn_id id,
+                  const void *value, int flags)
 {
   if (value) {
     uint32_t value_size = pat->value_size;
@@ -2187,7 +2188,8 @@ grn_pat_cursor_get_key_value(grn_ctx *ctx, grn_pat_cursor *c,
 }
 
 grn_rc
-grn_pat_cursor_set_value(grn_ctx *ctx, grn_pat_cursor *c, void *value, int flags)
+grn_pat_cursor_set_value(grn_ctx *ctx, grn_pat_cursor *c,
+                         const void *value, int flags)
 {
   return grn_pat_set_value(ctx, c->pat, c->curr_rec, value, flags);
 }

  Modified: test/unit/core/test-command-dump.c (+3 -3)
===================================================================
--- test/unit/core/test-command-dump.c    2012-01-10 15:59:59 +0900 (d8a87f6)
+++ test/unit/core/test-command-dump.c    2012-01-10 16:22:12 +0900 (5823c5b)
@@ -2,7 +2,7 @@
 /*
   Copyright (C) 2010 Brazil
   Copyright (C) 2009  Ryo Onodera <onode****@clear*****>
-  Copyright (C) 2009-2010  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2009-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -457,8 +457,8 @@ test_unsequantial_records_in_table_with_keys(void)
 {
   grn_obj *table;
   grn_id id, expected_id = 1;
-  char *keys[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-  int i, n_keys = sizeof(keys)/sizeof(keys[0]);
+  const gchar *keys[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+  int i, n_keys = sizeof(keys) / sizeof(keys[0]);
 
   table = table_create("Weekdays", GRN_OBJ_TABLE_HASH_KEY, "ShortText", NULL);
   grn_test_assert_context(context);

  Modified: test/unit/core/test-command-load.c (+1 -1)
===================================================================
--- test/unit/core/test-command-load.c    2012-01-10 15:59:59 +0900 (dfbbd95)
+++ test/unit/core/test-command-load.c    2012-01-10 16:22:12 +0900 (7f67089)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2010-2011  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2010-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public

  Modified: test/unit/core/test-hash.c (+2 -2)
===================================================================
--- test/unit/core/test-hash.c    2012-01-10 15:59:59 +0900 (b3b7757)
+++ test/unit/core/test-hash.c    2012-01-10 16:22:12 +0900 (45f8f04)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2008-2010  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2008-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -523,7 +523,7 @@ test_set_value(gconstpointer data)
   put_sample_entry();
 
   grn_test_assert(grn_hash_set_value(context, hash,
-                                    sample_id, "XXX", GRN_OBJ_SET));
+                                     sample_id, "XXX", GRN_OBJ_SET));
   cut_assert_equal_int(GRN_TEST_HASH_FACTORY_DEFAULT_VALUE_SIZE,
                        grn_hash_get_value(context, hash, sample_id, got_value));
   cut_assert_equal_string("XXX", got_value);

  Modified: test/unit/core/test-inverted-index.c (+8 -5)
===================================================================
--- test/unit/core/test-inverted-index.c    2012-01-10 15:59:59 +0900 (60eb6fb)
+++ test/unit/core/test-inverted-index.c    2012-01-10 16:22:12 +0900 (740b6e9)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2008-2011  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2008-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -261,7 +261,7 @@ test_open_invalid_segment_file(void)
 {
   grn_io *io;
   gchar *id_string;
-  gchar *expected_error_message = "syscall error";
+  const gchar *expected_error_message = "syscall error";
 
   io = grn_io_create(context, path, 10, 10, 10,
                      grn_io_auto, GRN_IO_EXPIRE_SEGMENT);
@@ -462,7 +462,8 @@ insert_and_search(grn_obj *users, grn_obj *items, grn_obj *checks, grn_obj *chec
 void
 test_array_index(void)
 {
-  gchar *db_path, *name;
+  gchar *db_path;
+  const gchar *name;
   grn_obj *users, *items, *checks, *checked;
 
   grn_obj_close(context, db);
@@ -506,7 +507,8 @@ test_array_index(void)
 void
 test_scalar_index(void)
 {
-  gchar *db_path, *name;
+  gchar *db_path;
+  const gchar *name;
   grn_obj *users, *items, *checks, *checked;
 
   grn_obj_close(context, db);
@@ -550,7 +552,8 @@ test_scalar_index(void)
 void
 test_int_index(void)
 {
-  gchar *db_path, *name;
+  gchar *db_path;
+  const gchar *name;
   grn_obj *users, *items, *checks, *checked, *int_type;
 
   grn_obj_close(context, db);

  Modified: test/unit/core/test-patricia-trie-search.c (+4 -3)
===================================================================
--- test/unit/core/test-patricia-trie-search.c    2012-01-10 15:59:59 +0900 (89af53f)
+++ test/unit/core/test-patricia-trie-search.c    2012-01-10 16:22:12 +0900 (dafc2ee)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2008-2009  Kouhei Sutou <kou****@cozmi*****>
+  Copyright (C) 2008-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -207,11 +207,12 @@ test_lcp_search(gconstpointer data)
 
 static grn_trie_test_data *xfix_test_data_new(grn_rc expected_rc,
                                               GList *expected_keys,
-                                              gchar *search_key,
+                                              const gchar *search_key,
                                               grn_test_set_parameters_func set_parameters,
                                               ...) G_GNUC_NULL_TERMINATED;
 static grn_trie_test_data *
-xfix_test_data_new(grn_rc expected_rc, GList *expected_keys, gchar *search_key,
+xfix_test_data_new(grn_rc expected_rc, GList *expected_keys,
+                   const gchar *search_key,
                    grn_test_set_parameters_func set_parameters, ...)
 {
   grn_trie_test_data *test_data;

  Modified: test/unit/core/test-patricia-trie.c (+2 -2)
===================================================================
--- test/unit/core/test-patricia-trie.c    2012-01-10 15:59:59 +0900 (8a0d34e)
+++ test/unit/core/test-patricia-trie.c    2012-01-10 16:22:12 +0900 (c9d981f)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2008-2010  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2008-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -529,7 +529,7 @@ test_set_value(void)
   put_sample_entry();
 
   grn_test_assert(grn_pat_set_value(context, trie,
-                                   sample_id, "XXX", GRN_OBJ_SET));
+                                    sample_id, "XXX", GRN_OBJ_SET));
   cut_assert_equal_int(DEFAULT_VALUE_SIZE,
                        grn_pat_get_value(context, trie, sample_id, got_value));
   cut_assert_equal_string("XXX", got_value);

  Modified: test/unit/core/test-table.c (+2 -2)
===================================================================
--- test/unit/core/test-table.c    2012-01-10 15:59:59 +0900 (41e5e37)
+++ test/unit/core/test-table.c    2012-01-10 16:22:12 +0900 (fb22b5d)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2009-2011  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2009-2012  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -117,7 +117,7 @@ test_array_set_data(void)
   grn_obj *record_value;
   grn_obj *retrieved_record_value;
   const gchar *dupped_retrieved_record_value;
-  gchar *value_type_name = "value_type";
+  const gchar *value_type_name = "value_type";
   grn_obj *value_type;
 
   value_type = grn_type_create(context,




Groonga-commit メーリングリストの案内
Back to archive index