From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] st: constify st_table * in public API
Date: Thu, 30 Jul 2015 00:17:44 +0000 [thread overview]
Message-ID: <1438215464-5881-1-git-send-email-e@80x24.org> (raw)
---
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
reply other threads:[~2015-07-30 0:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438215464-5881-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).