dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] st: constify st_table * in public API
@ 2015-07-30  0:17 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-07-30  0:17 UTC (permalink / raw)
  To: spew

---
 include/ruby/st.h | 14 +++++++-------
 st.c              | 16 +++++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/include/ruby/st.h b/include/ruby/st.h
index 190bad2..bfb1e1d 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -112,8 +112,8 @@ int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
 int st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
 int st_insert(st_table *, st_data_t, st_data_t);
 int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
-int st_lookup(st_table *, st_data_t, st_data_t *);
-int st_get_key(st_table *, st_data_t, st_data_t *);
+int st_lookup(const st_table *, st_data_t, st_data_t *);
+int st_get_key(const st_table *, st_data_t, st_data_t *);
 typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
 /* *key may be altered, but must equal to the old key, i.e., the
  * results of hash() are same and compare() returns 0, otherwise the
@@ -122,15 +122,15 @@ int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_
 int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
 int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
 int st_reverse_foreach(st_table *, int (*)(ANYARGS), st_data_t);
-st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
-st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
-st_index_t st_values(st_table *table, st_data_t *values, st_index_t size);
-st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never);
+st_index_t st_keys(const st_table *table, st_data_t *keys, st_index_t size);
+st_index_t st_keys_check(const st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
+st_index_t st_values(const st_table *table, st_data_t *values, st_index_t size);
+st_index_t st_values_check(const st_table *table, st_data_t *values, st_index_t size, st_data_t never);
 void st_add_direct(st_table *, st_data_t, st_data_t);
 void st_free_table(st_table *);
 void st_cleanup_safe(st_table *, st_data_t);
 void st_clear(st_table *);
-st_table *st_copy(st_table *);
+st_table *st_copy(const st_table *);
 int st_numcmp(st_data_t, st_data_t);
 st_index_t st_numhash(st_data_t);
 int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
diff --git a/st.c b/st.c
index 9b79704..2144d97 100644
--- a/st.c
+++ b/st.c
@@ -382,7 +382,7 @@ find_packed_index(const st_table *table, st_index_t hash_val, st_data_t key)
 #define collision_check 0
 
 int
-st_lookup(st_table *table, register st_data_t key, st_data_t *value)
+st_lookup(const st_table *table, register st_data_t key, st_data_t *value)
 {
     st_index_t hash_val;
     register st_table_entry *ptr;
@@ -410,7 +410,7 @@ st_lookup(st_table *table, register st_data_t key, st_data_t *value)
 }
 
 int
-st_get_key(st_table *table, register st_data_t key, st_data_t *result)
+st_get_key(const st_table *table, register st_data_t key, st_data_t *result)
 {
     st_index_t hash_val;
     register st_table_entry *ptr;
@@ -622,7 +622,7 @@ rehash(register st_table *table)
 }
 
 st_table*
-st_copy(st_table *old_table)
+st_copy(const st_table *old_table)
 {
     st_table *new_table;
     st_table_entry *ptr = 0, *entry;
@@ -1072,13 +1072,14 @@ get_keys(const st_table *table, st_data_t *keys, st_index_t size,
 }
 
 st_index_t
-st_keys(st_table *table, st_data_t *keys, st_index_t size)
+st_keys(const st_table *table, st_data_t *keys, st_index_t size)
 {
     return get_keys(table, keys, size, 0, 0);
 }
 
 st_index_t
-st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never)
+st_keys_check(const st_table *table, st_data_t *keys, st_index_t size,
+	      st_data_t never)
 {
     return get_keys(table, keys, size, 1, never);
 }
@@ -1116,13 +1117,14 @@ get_values(const st_table *table, st_data_t *values, st_index_t size,
 }
 
 st_index_t
-st_values(st_table *table, st_data_t *values, st_index_t size)
+st_values(const st_table *table, st_data_t *values, st_index_t size)
 {
     return get_values(table, values, size, 0, 0);
 }
 
 st_index_t
-st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never)
+st_values_check(const st_table *table, st_data_t *values, st_index_t size,
+                st_data_t never)
 {
     return get_values(table, values, size, 1, never);
 }
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-30  0:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30  0:17 [PATCH] st: constify st_table * in public API Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).