From 64a641cf2799c88ec11c002fc21badfb47983bf2 Mon Sep 17 00:00:00 2001 From: knu Date: Mon, 6 Jan 2003 15:55:43 +0000 Subject: * st.h, st.c: Introduce new conventional typedef's, st_data_t, st_compare_func_t, st_hash_func_t and st_each_func_t. * st.h, st.c: Do explicit function declarations and do not rely on implicit declarations. On such platforms as IA64, int argument values are NOT automatically promoted to long (64bit) values, so explicit declarations are mandatory for those functions that take long values or pointers. This fixes miniruby's coredump on FreeBSD/IA64. * class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c: Add proper casts to avoid warnings. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- st.c | 63 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 85391cac8..d9e8be497 100644 --- a/st.c +++ b/st.c @@ -5,6 +5,7 @@ #include "config.h" #include #include +#include #include "st.h" #ifdef _WIN32 @@ -15,8 +16,8 @@ typedef struct st_table_entry st_table_entry; struct st_table_entry { unsigned int hash; - char *key; - char *record; + st_data_t key; + st_data_t record; st_table_entry *next; }; @@ -32,18 +33,18 @@ struct st_table_entry { * allocated initially * */ -static int numcmp(); -static int numhash(); +static int numcmp(long, long); +static int numhash(long); static struct st_hash_type type_numhash = { numcmp, numhash, }; -extern int strcmp(); -static int strhash(); +/* extern int strcmp(const char *, const char *); */ +static int strhash(const char *); static struct st_hash_type type_strhash = { - strcmp, - strhash, + (st_compare_func_t)strcmp, + (st_hash_func_t)strhash, }; #ifdef RUBY_PLATFORM @@ -52,13 +53,13 @@ static struct st_hash_type type_strhash = { #define xrealloc ruby_xrealloc #define xfree ruby_xfree -void *xmalloc(); -void *xcalloc(); -void *xrealloc(); -void xfree(); +void *xmalloc(long); +void *xcalloc(long, long); +void *xrealloc(void *, long); +void xfree(void *); #endif -static void rehash(); +static void rehash(st_table *); #define alloc(type) (type*)xmalloc((unsigned)sizeof(type)) #define Calloc(n,s) (char*)xcalloc((n),(s)) @@ -180,7 +181,7 @@ st_init_table(type) } st_table* -st_init_numtable() +st_init_numtable(void) { return st_init_table(&type_numhash); } @@ -193,7 +194,7 @@ st_init_numtable_with_size(size) } st_table* -st_init_strtable() +st_init_strtable(void) { return st_init_table(&type_strhash); } @@ -248,8 +249,8 @@ st_free_table(table) int st_lookup(table, key, value) st_table *table; - register char *key; - char **value; + register st_data_t key; + st_data_t *value; { unsigned int hash_val, bin_pos; register st_table_entry *ptr; @@ -287,8 +288,8 @@ do {\ int st_insert(table, key, value) register st_table *table; - register char *key; - char *value; + register st_data_t key; + st_data_t value; { unsigned int hash_val, bin_pos; register st_table_entry *ptr; @@ -309,8 +310,8 @@ st_insert(table, key, value) void st_add_direct(table, key, value) st_table *table; - char *key; - char *value; + st_data_t key; + st_data_t value; { unsigned int hash_val, bin_pos; @@ -389,8 +390,8 @@ st_copy(old_table) int st_delete(table, key, value) register st_table *table; - register char **key; - char **value; + register st_data_t *key; + st_data_t *value; { unsigned int hash_val; st_table_entry *tmp; @@ -431,9 +432,9 @@ st_delete(table, key, value) int st_delete_safe(table, key, value, never) register st_table *table; - register char **key; - char **value; - char *never; + register st_data_t *key; + st_data_t *value; + st_data_t never; { unsigned int hash_val; register st_table_entry *ptr; @@ -461,7 +462,7 @@ st_delete_safe(table, key, value, never) static int delete_never(key, value, never) - char *key, *value, *never; + st_data_t key, value, never; { if (value == never) return ST_DELETE; return ST_CONTINUE; @@ -470,7 +471,7 @@ delete_never(key, value, never) void st_cleanup_safe(table, never) st_table *table; - char *never; + st_data_t never; { int num_entries = table->num_entries; @@ -481,8 +482,8 @@ st_cleanup_safe(table, never) void st_foreach(table, func, arg) st_table *table; - enum st_retval (*func)(); - char *arg; + st_each_func_t func; + st_data_t arg; { st_table_entry *ptr, *last, *tmp; enum st_retval retval; @@ -517,7 +518,7 @@ st_foreach(table, func, arg) static int strhash(string) - register char *string; + register const char *string; { register int c; -- cgit