mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Drop most 'const's from function prototypes
darcs-hash:20060612214742-ac50b-9b0801e8a7c07d6ab3f0acf569e1d6eb1eeb3f0e.gz
This commit is contained in:
parent
2c95e087b2
commit
9aee2b7c9c
18 changed files with 138 additions and 138 deletions
|
@ -517,7 +517,7 @@ int builtin_complete( wchar_t **argv )
|
|||
sb_printf( sb_out, L"%ls\n", next );
|
||||
}
|
||||
|
||||
al_foreach( &comp, (void (*)(const void *))&free );
|
||||
al_foreach( &comp, &free );
|
||||
al_destroy( &comp );
|
||||
recursion_level--;
|
||||
}
|
||||
|
@ -569,8 +569,8 @@ int builtin_complete( wchar_t **argv )
|
|||
}
|
||||
}
|
||||
|
||||
al_foreach( &cmd, (void (*)(const void *))&free );
|
||||
al_foreach( &path, (void (*)(const void *))&free );
|
||||
al_foreach( &cmd, &free );
|
||||
al_foreach( &path, &free );
|
||||
|
||||
al_destroy( &cmd );
|
||||
al_destroy( &path );
|
||||
|
|
|
@ -745,10 +745,10 @@ int builtin_set( wchar_t **argv )
|
|||
}
|
||||
}
|
||||
|
||||
al_foreach( &result, (void (*)(const void *))&free );
|
||||
al_foreach( &result, &free );
|
||||
al_destroy( &result );
|
||||
|
||||
al_foreach( &indexes, (void (*)(const void *))&free );
|
||||
al_foreach( &indexes, &free );
|
||||
al_destroy(&indexes);
|
||||
al_destroy(&values);
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ static void complete_free_entry( complete_entry *c )
|
|||
/**
|
||||
Free hash key and hash value
|
||||
*/
|
||||
static void clear_hash_entry( const void *key, const void *data )
|
||||
static void clear_hash_entry( void *key, void *data )
|
||||
{
|
||||
free( (void *)key );
|
||||
free( (void *)data );
|
||||
|
@ -918,7 +918,7 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig )
|
|||
}
|
||||
}
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp )
|
|||
|
||||
hash_destroy( &lookup );
|
||||
al_foreach( &list,
|
||||
(void(*)(const void *))&free );
|
||||
&free );
|
||||
al_destroy( &list );
|
||||
free( lookup_cmd );
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ static void complete_from_args( const wchar_t *str,
|
|||
|
||||
copy_strings_with_prefix( comp_out, str, desc, 0, &possible_comp );
|
||||
|
||||
al_foreach( &possible_comp, (void (*)(const void *))&free );
|
||||
al_foreach( &possible_comp, &free );
|
||||
al_destroy( &possible_comp );
|
||||
}
|
||||
|
||||
|
|
24
env.c
24
env.c
|
@ -188,7 +188,7 @@ static const wchar_t *locale_variable[] =
|
|||
/**
|
||||
Free hash key and hash value
|
||||
*/
|
||||
static void clear_hash_entry( const void *key, const void *data )
|
||||
static void clear_hash_entry( void *key, void *data )
|
||||
{
|
||||
var_entry_t *entry = (var_entry_t *)data;
|
||||
if( entry->export )
|
||||
|
@ -435,14 +435,14 @@ static void setup_path()
|
|||
|
||||
sb_destroy( &b );
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_foreach( &l, &free );
|
||||
path = env_get( L"PATH" );
|
||||
al_truncate( &l, 0 );
|
||||
tokenize_variable_array( path, &l );
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ int env_set( const wchar_t *key,
|
|||
if( !done )
|
||||
{
|
||||
void *k, *v;
|
||||
hash_remove( &node->env, key, (const void **)&k, (const void **)&v );
|
||||
hash_remove( &node->env, key, &k, &v );
|
||||
free( k );
|
||||
free( v );
|
||||
|
||||
|
@ -831,7 +831,7 @@ static int try_remove( env_node_t *n,
|
|||
const wchar_t *key,
|
||||
int var_mode )
|
||||
{
|
||||
const void *old_key_void, *old_val_void;
|
||||
void *old_key_void, *old_val_void;
|
||||
wchar_t *old_key, *old_val;
|
||||
|
||||
if( n == 0 )
|
||||
|
@ -1176,8 +1176,8 @@ void env_pop()
|
|||
Function used with hash_foreach to insert keys of one table into
|
||||
another
|
||||
*/
|
||||
static void add_key_to_hash( const void *key,
|
||||
const void *data,
|
||||
static void add_key_to_hash( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)data;
|
||||
|
@ -1191,7 +1191,7 @@ static void add_key_to_hash( const void *key,
|
|||
/**
|
||||
Add key to hashtable
|
||||
*/
|
||||
static void add_to_hash( const void *k, void *aux )
|
||||
static void add_to_hash( void *k, void *aux )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux,
|
||||
k,
|
||||
|
@ -1201,8 +1201,8 @@ static void add_to_hash( const void *k, void *aux )
|
|||
/**
|
||||
Add key to list
|
||||
*/
|
||||
static void add_key_to_list( const void * key,
|
||||
const void * val,
|
||||
static void add_key_to_list( void * key,
|
||||
void * val,
|
||||
void *aux )
|
||||
{
|
||||
al_push( (array_list_t *)aux, key );
|
||||
|
@ -1286,7 +1286,7 @@ void env_get_names( array_list_t *l, int flags )
|
|||
/**
|
||||
Function used by env_export_arr to iterate over hashtable of variables
|
||||
*/
|
||||
static void export_func1( const void *k, const void *v, void *aux )
|
||||
static void export_func1( void *k, void *v, void *aux )
|
||||
{
|
||||
var_entry_t *val_entry = (var_entry_t *)v;
|
||||
if( val_entry->export )
|
||||
|
@ -1302,7 +1302,7 @@ static void export_func1( const void *k, const void *v, void *aux )
|
|||
/**
|
||||
Function used by env_export_arr to iterate over hashtable of variables
|
||||
*/
|
||||
static void export_func2( const void *k, const void *v, void *aux )
|
||||
static void export_func2( void *k, void *v, void *aux )
|
||||
{
|
||||
wchar_t *key = (wchar_t *)k;
|
||||
wchar_t *val = (wchar_t *)v;
|
||||
|
|
|
@ -116,8 +116,8 @@ void env_universal_common_init( void (*cb)(int type, const wchar_t *key, const w
|
|||
/**
|
||||
Free both key and data
|
||||
*/
|
||||
static void erase( const void *key,
|
||||
const void *data )
|
||||
static void erase( void *key,
|
||||
void *data )
|
||||
{
|
||||
free( (void *)key );
|
||||
free( (void *)data );
|
||||
|
@ -205,8 +205,8 @@ static void remove_entry( wchar_t *name )
|
|||
void *k, *v;
|
||||
hash_remove( &env_universal_var,
|
||||
name,
|
||||
(const void **)&k,
|
||||
(const void **)&v );
|
||||
&k,
|
||||
&v );
|
||||
free( k );
|
||||
free( v );
|
||||
}
|
||||
|
@ -498,8 +498,8 @@ message_t *create_message( int type,
|
|||
Function used with hash_foreach to insert keys of one table into
|
||||
another
|
||||
*/
|
||||
static void add_key_to_hash( const void *key,
|
||||
const void *data,
|
||||
static void add_key_to_hash( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_uni_entry_t *e = (var_uni_entry_t *)data;
|
||||
|
@ -546,8 +546,8 @@ int env_universal_common_get_export( const wchar_t *name )
|
|||
\param v the variable value
|
||||
\param q the queue to add the message to
|
||||
*/
|
||||
static void enqueue( const void *k,
|
||||
const void *v,
|
||||
static void enqueue( void *k,
|
||||
void *v,
|
||||
void *q)
|
||||
{
|
||||
const wchar_t *key = (const wchar_t *)k;
|
||||
|
|
6
event.c
6
event.c
|
@ -627,7 +627,7 @@ void event_destroy()
|
|||
|
||||
if( events )
|
||||
{
|
||||
al_foreach( events, (void (*)(const void *))&event_free );
|
||||
al_foreach( events, (void (*)(void *))&event_free );
|
||||
al_destroy( events );
|
||||
free( events );
|
||||
events=0;
|
||||
|
@ -635,7 +635,7 @@ void event_destroy()
|
|||
|
||||
if( killme )
|
||||
{
|
||||
al_foreach( killme, (void (*)(const void *))&event_free );
|
||||
al_foreach( killme, (void (*)(void *))&event_free );
|
||||
al_destroy( killme );
|
||||
free( killme );
|
||||
killme=0;
|
||||
|
@ -647,7 +647,7 @@ void event_free( event_t *e )
|
|||
/*
|
||||
When apropriate, we clear the argument vector
|
||||
*/
|
||||
al_foreach( &e->arguments, (void (*)(const void *))&free );
|
||||
al_foreach( &e->arguments, &free );
|
||||
al_destroy( &e->arguments );
|
||||
|
||||
free( (void *)e->function_name );
|
||||
|
|
8
expand.c
8
expand.c
|
@ -837,7 +837,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
|||
}
|
||||
}
|
||||
/* Free remaining strings in list l and truncate it */
|
||||
al_foreach( &var_item_list, (void (*)(const void *))&free );
|
||||
al_foreach( &var_item_list, &free );
|
||||
al_truncate( &var_item_list, 0 );
|
||||
/* Add items from list idx back to list l */
|
||||
al_push_all( &var_item_list, var_idx_list );
|
||||
|
@ -1163,7 +1163,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
|
|||
|
||||
if( exec_subshell( subcmd, &sub_res)==-1 )
|
||||
{
|
||||
al_foreach( &sub_res, (void (*)(const void *))&free );
|
||||
al_foreach( &sub_res, &free );
|
||||
al_destroy( &sub_res );
|
||||
free( subcmd );
|
||||
return 0;
|
||||
|
@ -1202,7 +1202,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
|
|||
|
||||
al_destroy( &sub_res );
|
||||
|
||||
al_foreach( &tail_expand, (void (*)(const void *))&free );
|
||||
al_foreach( &tail_expand, &free );
|
||||
al_destroy( &tail_expand );
|
||||
|
||||
free( subcmd );
|
||||
|
@ -1630,7 +1630,7 @@ wchar_t *expand_one( void *context, wchar_t *string, int flags )
|
|||
}
|
||||
}
|
||||
|
||||
al_foreach( &l, (void(*)(const void *))&free );
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
|
||||
halloc_register( context, one );
|
||||
|
|
20
function.c
20
function.c
|
@ -116,7 +116,7 @@ static void autoload_names( array_list_t *out, int get_hidden )
|
|||
}
|
||||
closedir(dir);
|
||||
}
|
||||
al_foreach( &path_list, (void (*)(const void *))&free );
|
||||
al_foreach( &path_list, &free );
|
||||
al_destroy( &path_list );
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,8 @@ static void autoload_names( array_list_t *out, int get_hidden )
|
|||
/**
|
||||
Free all contents of an entry to the function hash table
|
||||
*/
|
||||
static void clear_function_entry( const void *key,
|
||||
const void *data )
|
||||
static void clear_function_entry( void *key,
|
||||
void *data )
|
||||
{
|
||||
function_data_t *d = (function_data_t *)data;
|
||||
free( (void *)d->cmd );
|
||||
|
@ -209,7 +209,7 @@ int function_exists( const wchar_t *cmd )
|
|||
void function_remove( const wchar_t *name )
|
||||
{
|
||||
void *key;
|
||||
const void *dv;
|
||||
void *dv;
|
||||
function_data_t *d;
|
||||
event_t ev;
|
||||
|
||||
|
@ -221,7 +221,7 @@ void function_remove( const wchar_t *name )
|
|||
|
||||
hash_remove( &function,
|
||||
name,
|
||||
(const void **) &key,
|
||||
&key,
|
||||
&dv );
|
||||
|
||||
d=(function_data_t *)dv;
|
||||
|
@ -303,8 +303,8 @@ static int al_contains_str( array_list_t *list, const wchar_t * str )
|
|||
/**
|
||||
Helper function for removing hidden functions
|
||||
*/
|
||||
static void get_names_internal( const void *key,
|
||||
const void *val,
|
||||
static void get_names_internal( void *key,
|
||||
void *val,
|
||||
void *aux )
|
||||
{
|
||||
wchar_t *name = (wchar_t *)key;
|
||||
|
@ -319,9 +319,9 @@ static void get_names_internal( const void *key,
|
|||
/**
|
||||
Helper function for removing hidden functions
|
||||
*/
|
||||
static void get_names_internal_all( const void *key,
|
||||
const void *val,
|
||||
void *aux )
|
||||
static void get_names_internal_all( void *key,
|
||||
void *val,
|
||||
void *aux )
|
||||
{
|
||||
wchar_t *name = (wchar_t *)key;
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ static void history_save()
|
|||
Save the specified mode to file
|
||||
*/
|
||||
|
||||
static void history_destroy_mode( const void *name, const void *link )
|
||||
static void history_destroy_mode( void *name, void *link )
|
||||
{
|
||||
mode_name = (wchar_t *)name;
|
||||
history_data *d = (history_data *)link;
|
||||
|
|
4
input.c
4
input.c
|
@ -1,5 +1,5 @@
|
|||
/** \file input.c
|
||||
|
||||
a
|
||||
Functions for reading a character of input from stdin, using the
|
||||
inputrc information for key bindings.
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ int input_init()
|
|||
/**
|
||||
Free memory used by the specified mapping
|
||||
*/
|
||||
static void destroy_mapping( const void *key, const void *val )
|
||||
static void destroy_mapping( void *key, void *val )
|
||||
{
|
||||
int i;
|
||||
array_list_t *mappings = (array_list_t *)val;
|
||||
|
|
2
intern.c
2
intern.c
|
@ -100,7 +100,7 @@ const wchar_t *intern_static( const wchar_t *in )
|
|||
/**
|
||||
Free the specified key/value pair. Should only be called by intern_free_all at shutdown
|
||||
*/
|
||||
static void clear_value( const void *key, const void *data )
|
||||
static void clear_value( void *key, void *data )
|
||||
{
|
||||
debug( 3, L"interned string: '%ls'", data );
|
||||
free( (void *)data );
|
||||
|
|
2
kill.c
2
kill.c
|
@ -179,7 +179,7 @@ static void kill_check_x_buffer()
|
|||
}
|
||||
}
|
||||
|
||||
al_foreach( &list, (void (*)(const void *))&free );
|
||||
al_foreach( &list, &free );
|
||||
al_destroy( &list );
|
||||
}
|
||||
}
|
||||
|
|
2
mimedb.c
2
mimedb.c
|
@ -1120,7 +1120,7 @@ static void launch( char *filter, array_list_t *files, int fileno )
|
|||
/**
|
||||
Clean up one entry from the hash table of launch files
|
||||
*/
|
||||
static void clear_entry( const void *key, const void *val )
|
||||
static void clear_entry( void *key, void *val )
|
||||
{
|
||||
/*
|
||||
The key is a mime value, either from the libraries internal hash
|
||||
|
|
4
output.c
4
output.c
|
@ -544,9 +544,9 @@ int output_color_code( const wchar_t *val )
|
|||
|
||||
}
|
||||
|
||||
al_foreach( &el, (void (*)(const void *))&free );
|
||||
al_foreach( &el, &free );
|
||||
al_destroy( &el );
|
||||
|
||||
|
||||
return color | (is_bold?FISH_COLOR_BOLD:0);
|
||||
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ void parse_util_token_extent( const wchar_t *buff,
|
|||
/**
|
||||
Free hash value, but not hash key
|
||||
*/
|
||||
static void clear_hash_value( const void *key, const void *data )
|
||||
static void clear_hash_value( void *key, void *data )
|
||||
{
|
||||
free( (void *)data );
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ static void clear_hash_value( const void *key, const void *data )
|
|||
/**
|
||||
Part of the autoloader cleanup
|
||||
*/
|
||||
static void clear_loaded_entry( const void *key, const void *data )
|
||||
static void clear_loaded_entry( void *key, void *data )
|
||||
{
|
||||
hash_table_t *loaded = (hash_table_t *)data;
|
||||
hash_foreach( loaded,
|
||||
|
@ -474,7 +474,7 @@ void parse_util_load_reset( const wchar_t *path_var )
|
|||
if( all_loaded )
|
||||
{
|
||||
void *key, *data;
|
||||
hash_remove( all_loaded, path_var, (const void **)&key, (const void **)&data );
|
||||
hash_remove( all_loaded, path_var, &key, &data );
|
||||
if( key )
|
||||
clear_loaded_entry( key, data );
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ int parse_util_load( const wchar_t *cmd,
|
|||
hash_put( loaded, intern( cmd ), tm );
|
||||
}
|
||||
|
||||
al_foreach( path_list, (void (*)(const void *))&free );
|
||||
al_foreach( path_list, &free );
|
||||
al_truncate( path_list, 0 );
|
||||
|
||||
return reloaded;
|
||||
|
|
16
reader.c
16
reader.c
|
@ -660,7 +660,7 @@ void reader_write_title()
|
|||
}
|
||||
proc_pop_interactive();
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
set_color( FISH_COLOR_RESET, FISH_COLOR_RESET );
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ static void write_prompt()
|
|||
if( data->exec_prompt )
|
||||
{
|
||||
|
||||
al_foreach( &prompt_list, (void (*)(const void *))&free );
|
||||
al_foreach( &prompt_list, &free );
|
||||
al_truncate( &prompt_list, 0 );
|
||||
|
||||
if( data->prompt )
|
||||
|
@ -814,7 +814,7 @@ static void write_prompt()
|
|||
if( exec_subshell( data->prompt, &prompt_list ) == -1 )
|
||||
{
|
||||
/* If executing the prompt fails, make sure we at least don't print any junk */
|
||||
al_foreach( &prompt_list, (void (*)(const void *))&free );
|
||||
al_foreach( &prompt_list, &free );
|
||||
al_destroy( &prompt_list );
|
||||
al_init( &prompt_list );
|
||||
}
|
||||
|
@ -1674,7 +1674,7 @@ static void reader_interactive_init()
|
|||
static void reader_interactive_destroy()
|
||||
{
|
||||
kill_destroy();
|
||||
al_foreach( &prompt_list, (void (*)(const void *))&free );
|
||||
al_foreach( &prompt_list, &free );
|
||||
al_destroy( &prompt_list );
|
||||
|
||||
writestr( L"\n" );
|
||||
|
@ -1776,7 +1776,7 @@ static void reset_token_history()
|
|||
|
||||
data->token_history_pos = -1;
|
||||
data->search_pos=0;
|
||||
al_foreach( &data->search_prev, (void (*)(const void *))&free );
|
||||
al_foreach( &data->search_prev, &free );
|
||||
al_truncate( &data->search_prev, 0 );
|
||||
al_push( &data->search_prev, wcsdup( data->search_buff ) );
|
||||
}
|
||||
|
@ -2172,7 +2172,7 @@ void reader_pop()
|
|||
/*
|
||||
Clean up after history search
|
||||
*/
|
||||
al_foreach( &n->search_prev, (void (*)(const void *))&free );
|
||||
al_foreach( &n->search_prev, &free );
|
||||
al_destroy( &n->search_prev );
|
||||
free( (void *)n->token_history_buff);
|
||||
|
||||
|
@ -2438,7 +2438,7 @@ wchar_t *reader_readline()
|
|||
|
||||
if( (last_char == R_COMPLETE) && (c != R_COMPLETE) && (!comp_empty) )
|
||||
{
|
||||
al_foreach( &comp, (void (*)(const void *))&free );
|
||||
al_foreach( &comp, &free );
|
||||
al_truncate( &comp, 0 );
|
||||
comp_empty = 1;
|
||||
}
|
||||
|
@ -2523,7 +2523,7 @@ wchar_t *reader_readline()
|
|||
if( (comp_empty =
|
||||
handle_completions( &comp ) ) )
|
||||
{
|
||||
al_foreach( &comp, (void (*)(const void *))&free );
|
||||
al_foreach( &comp, &free );
|
||||
al_truncate( &comp, 0 );
|
||||
}
|
||||
|
||||
|
|
78
util.c
78
util.c
|
@ -175,8 +175,8 @@ int q_empty( dyn_queue_t *q )
|
|||
/* Hash table functions */
|
||||
|
||||
void hash_init2( hash_table_t *h,
|
||||
int (*hash_func)(const void *key),
|
||||
int (*compare_func)(const void *key1, const void *key2),
|
||||
int (*hash_func)(void *key),
|
||||
int (*compare_func)(void *key1, void *key2),
|
||||
size_t capacity)
|
||||
{
|
||||
int i;
|
||||
|
@ -192,8 +192,8 @@ void hash_init2( hash_table_t *h,
|
|||
}
|
||||
|
||||
void hash_init( hash_table_t *h,
|
||||
int (*hash_func)(const void *key),
|
||||
int (*compare_func)(const void *key1, const void *key2) )
|
||||
int (*hash_func)(void *key),
|
||||
int (*compare_func)(void *key1, void *key2) )
|
||||
{
|
||||
h->arr = 0;
|
||||
h->size = 0;
|
||||
|
@ -213,7 +213,7 @@ void hash_destroy( hash_table_t *h )
|
|||
\return index in the table, or to the first free index if the key is not in the table
|
||||
*/
|
||||
static int hash_search( hash_table_t *h,
|
||||
const void *key )
|
||||
void *key )
|
||||
{
|
||||
int hv;
|
||||
int pos;
|
||||
|
@ -290,38 +290,38 @@ int hash_put( hash_table_t *h,
|
|||
}
|
||||
}
|
||||
|
||||
pos = hash_search( h, key );
|
||||
pos = hash_search( h, (void *)key );
|
||||
|
||||
if( h->arr[pos].key == 0 )
|
||||
{
|
||||
h->count++;
|
||||
}
|
||||
|
||||
h->arr[pos].key = key;
|
||||
h->arr[pos].data = data;
|
||||
h->arr[pos].key = (void *)key;
|
||||
h->arr[pos].data = (void *)data;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const void *hash_get( hash_table_t *h,
|
||||
const void *key )
|
||||
void *hash_get( hash_table_t *h,
|
||||
const void *key )
|
||||
{
|
||||
if( !h->count )
|
||||
return 0;
|
||||
|
||||
int pos = hash_search( h, key );
|
||||
int pos = hash_search( h, (void *)key );
|
||||
if( h->arr[pos].key == 0 )
|
||||
return 0;
|
||||
else
|
||||
return h->arr[pos].data;
|
||||
}
|
||||
|
||||
const void *hash_get_key( hash_table_t *h,
|
||||
const void *key )
|
||||
void *hash_get_key( hash_table_t *h,
|
||||
const void *key )
|
||||
{
|
||||
if( !h->count )
|
||||
return 0;
|
||||
|
||||
int pos = hash_search( h, key );
|
||||
int pos = hash_search( h, (void *)key );
|
||||
if( h->arr[pos].key == 0 )
|
||||
return 0;
|
||||
else
|
||||
|
@ -335,8 +335,8 @@ int hash_get_count( hash_table_t *h)
|
|||
|
||||
void hash_remove( hash_table_t *h,
|
||||
const void *key,
|
||||
const void **old_key,
|
||||
const void **old_val )
|
||||
void **old_key,
|
||||
void **old_val )
|
||||
{
|
||||
if( !h->count )
|
||||
{
|
||||
|
@ -348,7 +348,7 @@ void hash_remove( hash_table_t *h,
|
|||
return;
|
||||
}
|
||||
|
||||
int pos = hash_search( h, key );
|
||||
int pos = hash_search( h, (void *)key );
|
||||
int next_pos;
|
||||
|
||||
if( h->arr[pos].key == 0 )
|
||||
|
@ -407,15 +407,15 @@ int hash_contains( hash_table_t *h,
|
|||
if( !h->count )
|
||||
return 0;
|
||||
|
||||
int pos = hash_search( h, key );
|
||||
int pos = hash_search( h, (void *)key );
|
||||
return h->arr[pos].key != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Push hash value into array_list_t
|
||||
*/
|
||||
static void hash_put_data( const void *key,
|
||||
const void *data,
|
||||
static void hash_put_data( void *key,
|
||||
void *data,
|
||||
void *al )
|
||||
{
|
||||
al_push( (array_list_t *)al,
|
||||
|
@ -432,7 +432,7 @@ void hash_get_data( hash_table_t *h,
|
|||
/**
|
||||
Push hash key into array_list_t
|
||||
*/
|
||||
static void hash_put_key( const void *key, const void *data, void *al )
|
||||
static void hash_put_key( void *key, void *data, void *al )
|
||||
{
|
||||
al_push( (array_list_t *)al, key );
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ void hash_get_keys( hash_table_t *h,
|
|||
}
|
||||
|
||||
void hash_foreach( hash_table_t *h,
|
||||
void (*func)(const void *, const void *) )
|
||||
void (*func)( void *, void *) )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<h->size; i++ )
|
||||
|
@ -458,7 +458,7 @@ void hash_foreach( hash_table_t *h,
|
|||
}
|
||||
|
||||
void hash_foreach2( hash_table_t *h,
|
||||
void (*func)( const void *, const void *, void * ),
|
||||
void (*func)( void *, void *, void * ),
|
||||
void *aux )
|
||||
{
|
||||
int i;
|
||||
|
@ -472,7 +472,7 @@ void hash_foreach2( hash_table_t *h,
|
|||
}
|
||||
|
||||
|
||||
int hash_str_cmp( const void *a, const void *b )
|
||||
int hash_str_cmp( void *a, void *b )
|
||||
{
|
||||
return strcmp((char *)a,(char *)b) == 0;
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ static uint rotl5( uint in )
|
|||
}
|
||||
|
||||
|
||||
int hash_str_func( const void *data )
|
||||
int hash_str_func( void *data )
|
||||
{
|
||||
int res = 0x67452301u;
|
||||
const char *str = data;
|
||||
|
@ -497,7 +497,7 @@ int hash_str_func( const void *data )
|
|||
return res;
|
||||
}
|
||||
|
||||
int hash_wcs_func( const void *data )
|
||||
int hash_wcs_func( void *data )
|
||||
{
|
||||
int res = 0x67452301u;
|
||||
const wchar_t *str = data;
|
||||
|
@ -509,12 +509,12 @@ int hash_wcs_func( const void *data )
|
|||
}
|
||||
|
||||
|
||||
int hash_wcs_cmp( const void *a, const void *b )
|
||||
int hash_wcs_cmp( void *a, void *b )
|
||||
{
|
||||
return wcscmp((wchar_t *)a,(wchar_t *)b) == 0;
|
||||
}
|
||||
|
||||
int hash_ptr_func( const void *data )
|
||||
int hash_ptr_func( void *data )
|
||||
{
|
||||
return (int)(long) data;
|
||||
}
|
||||
|
@ -522,8 +522,8 @@ int hash_ptr_func( const void *data )
|
|||
/**
|
||||
Hash comparison function suitable for direct pointer comparison
|
||||
*/
|
||||
int hash_ptr_cmp( const void *a,
|
||||
const void *b )
|
||||
int hash_ptr_cmp( void *a,
|
||||
void *b )
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ int al_push( array_list_t *l, const void *o )
|
|||
l->arr = tmp;
|
||||
l->size = new_size;
|
||||
}
|
||||
l->arr[l->pos++] = o;
|
||||
l->arr[l->pos++] = (void *)o;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ int al_set( array_list_t *l, int pos, const void *o )
|
|||
return 0;
|
||||
if( pos < l->pos )
|
||||
{
|
||||
l->arr[pos] = o;
|
||||
l->arr[pos] = (void *)o;
|
||||
return 1;
|
||||
}
|
||||
old_pos=l->pos;
|
||||
|
@ -734,7 +734,7 @@ int al_set( array_list_t *l, int pos, const void *o )
|
|||
return 0;
|
||||
}
|
||||
|
||||
const void *al_get( array_list_t *l, int pos )
|
||||
void *al_get( array_list_t *l, int pos )
|
||||
{
|
||||
if( pos < 0 )
|
||||
return 0;
|
||||
|
@ -748,12 +748,12 @@ void al_truncate( array_list_t *l, int new_sz )
|
|||
l->pos = new_sz;
|
||||
}
|
||||
|
||||
const void *al_pop( array_list_t *l )
|
||||
void *al_pop( array_list_t *l )
|
||||
{
|
||||
const void *e = l->arr[--l->pos];
|
||||
void *e = l->arr[--l->pos];
|
||||
if( (l->pos*3 < l->size) && (l->size < MIN_SIZE) )
|
||||
{
|
||||
const void ** old_arr = l->arr;
|
||||
void ** old_arr = l->arr;
|
||||
int old_size = l->size;
|
||||
l->size = l->size/2;
|
||||
l->arr = realloc( l->arr, sizeof(void*)*l->size );
|
||||
|
@ -766,7 +766,7 @@ const void *al_pop( array_list_t *l )
|
|||
return e;
|
||||
}
|
||||
|
||||
const void *al_peek( array_list_t *l )
|
||||
void *al_peek( array_list_t *l )
|
||||
{
|
||||
|
||||
return l->pos>0?l->arr[l->pos-1]:0;
|
||||
|
@ -783,14 +783,14 @@ int al_get_count( array_list_t *l )
|
|||
return l->pos;
|
||||
}
|
||||
|
||||
void al_foreach( array_list_t *l, void (*func)( const void * ))
|
||||
void al_foreach( array_list_t *l, void (*func)( void * ))
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<l->pos; i++ )
|
||||
func( l->arr[i] );
|
||||
}
|
||||
|
||||
void al_foreach2( array_list_t *l, void (*func)( const void *, void *), void *aux)
|
||||
void al_foreach2( array_list_t *l, void (*func)( void *, void *), void *aux)
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<l->pos; i++ )
|
||||
|
|
66
util.h
66
util.h
|
@ -31,9 +31,9 @@ dyn_queue_t;
|
|||
typedef struct
|
||||
{
|
||||
/** Hash key*/
|
||||
const void *key;
|
||||
void *key;
|
||||
/** Value */
|
||||
const void *data;
|
||||
void *data;
|
||||
}
|
||||
hash_struct_t;
|
||||
|
||||
|
@ -61,9 +61,9 @@ typedef struct hash_table
|
|||
/** Length of array */
|
||||
int size;
|
||||
/** Hash function */
|
||||
int (*hash_func)( const void *key );
|
||||
int (*hash_func)( void *key );
|
||||
/** Comparison function */
|
||||
int (*compare_func)( const void *key1, const void *key2 );
|
||||
int (*compare_func)( void *key1, void *key2 );
|
||||
}
|
||||
hash_table_t;
|
||||
|
||||
|
@ -93,7 +93,7 @@ priority_queue_t;
|
|||
typedef struct array_list
|
||||
{
|
||||
/** Array containing the data */
|
||||
const void **arr;
|
||||
void **arr;
|
||||
/** Position to append elements at*/
|
||||
int pos;
|
||||
/** Length of array */
|
||||
|
@ -195,15 +195,15 @@ int q_empty( dyn_queue_t *q );
|
|||
Initialize a hash table. The hash function must never return the value 0.
|
||||
*/
|
||||
void hash_init( hash_table_t *h,
|
||||
int (*hash_func)(const void *key),
|
||||
int (*compare_func)(const void *key1, const void *key2) );
|
||||
int (*hash_func)( void *key),
|
||||
int (*compare_func)( void *key1, void *key2 ) );
|
||||
|
||||
/**
|
||||
Initialize a hash table. The hash function must never return the value 0.
|
||||
*/
|
||||
void hash_init2( hash_table_t *h,
|
||||
int (*hash_func)(const void *key),
|
||||
int (*compare_func)(const void *key1, const void *key2),
|
||||
int (*hash_func)( void *key ),
|
||||
int (*compare_func)( void *key1, void *key2 ),
|
||||
size_t capacity);
|
||||
|
||||
/**
|
||||
|
@ -219,13 +219,13 @@ int hash_put( hash_table_t *h,
|
|||
/**
|
||||
Returns the data with the associated key, or 0 if no such key is in the hashtable
|
||||
*/
|
||||
const void *hash_get( hash_table_t *h,
|
||||
const void *key );
|
||||
void *hash_get( hash_table_t *h,
|
||||
const void *key );
|
||||
/**
|
||||
Returns the hash tables version of the specified key
|
||||
*/
|
||||
const void *hash_get_key( hash_table_t *h,
|
||||
const void *key );
|
||||
void *hash_get_key( hash_table_t *h,
|
||||
const void *key );
|
||||
|
||||
/**
|
||||
Returns the number of key/data pairs in the table.
|
||||
|
@ -241,8 +241,8 @@ int hash_get_count( hash_table_t *h);
|
|||
*/
|
||||
void hash_remove( hash_table_t *h,
|
||||
const void *key,
|
||||
const void **old_key,
|
||||
const void **old_data );
|
||||
void **old_key,
|
||||
void **old_data );
|
||||
|
||||
/**
|
||||
Checks whether the specified key is in the hash table
|
||||
|
@ -266,49 +266,49 @@ void hash_get_data( hash_table_t *h,
|
|||
Call the function func for each key/data pair in the table
|
||||
*/
|
||||
void hash_foreach( hash_table_t *h,
|
||||
void (*func)( const void *, const void * ) );
|
||||
void (*func)( void *, void * ) );
|
||||
|
||||
/**
|
||||
Same as hash_foreach, but the function func takes an additional
|
||||
argument, which is provided by the caller in the variable aux
|
||||
*/
|
||||
void hash_foreach2( hash_table_t *h, void (*func)( const void *,
|
||||
const void *,
|
||||
void *),
|
||||
void hash_foreach2( hash_table_t *h, void (*func)( void *,
|
||||
void *,
|
||||
void *),
|
||||
void *aux );
|
||||
|
||||
/**
|
||||
Hash function suitable for character strings.
|
||||
*/
|
||||
int hash_str_func( const void *data );
|
||||
int hash_str_func( void *data );
|
||||
/**
|
||||
Hash comparison function suitable for character strings
|
||||
*/
|
||||
int hash_str_cmp( const void *a,
|
||||
const void *b );
|
||||
int hash_str_cmp( void *a,
|
||||
void *b );
|
||||
|
||||
/**
|
||||
Hash function suitable for wide character strings.
|
||||
*/
|
||||
int hash_wcs_func( const void *data );
|
||||
int hash_wcs_func( void *data );
|
||||
|
||||
/**
|
||||
Hash comparison function suitable for wide character strings
|
||||
*/
|
||||
int hash_wcs_cmp( const void *a,
|
||||
const void *b );
|
||||
int hash_wcs_cmp( void *a,
|
||||
void *b );
|
||||
|
||||
/**
|
||||
Hash function suitable for direct pointer comparison
|
||||
*/
|
||||
int hash_ptr_func( const void *data );
|
||||
int hash_ptr_func( void *data );
|
||||
|
||||
|
||||
/**
|
||||
Hash comparison function suitable for direct pointer comparison
|
||||
*/
|
||||
int hash_ptr_cmp( const void *a,
|
||||
const void *b );
|
||||
int hash_ptr_cmp( void *a,
|
||||
void *b );
|
||||
|
||||
|
||||
|
||||
|
@ -404,7 +404,7 @@ int al_set( array_list_t *l, int pos, const void *o );
|
|||
\param pos The index
|
||||
\return The element
|
||||
*/
|
||||
const void *al_get( array_list_t *l, int pos );
|
||||
void *al_get( array_list_t *l, int pos );
|
||||
|
||||
/**
|
||||
Truncates the list to new_sz items.
|
||||
|
@ -414,7 +414,7 @@ void al_truncate( array_list_t *l, int new_sz );
|
|||
/**
|
||||
Removes and returns the last entry in the list
|
||||
*/
|
||||
const void *al_pop( array_list_t *l );
|
||||
void *al_pop( array_list_t *l );
|
||||
|
||||
/**
|
||||
Returns the number of elements in the list
|
||||
|
@ -424,7 +424,7 @@ int al_get_count( array_list_t *l );
|
|||
/**
|
||||
Returns the last entry in the list witout removing it.
|
||||
*/
|
||||
const void *al_peek( array_list_t *l );
|
||||
void *al_peek( array_list_t *l );
|
||||
|
||||
/**
|
||||
Returns 1 if the list is empty, 0 otherwise
|
||||
|
@ -434,13 +434,13 @@ int al_empty( array_list_t *l);
|
|||
/**
|
||||
Call the function func for each entry in the list
|
||||
*/
|
||||
void al_foreach( array_list_t *l, void (*func)(const void * ));
|
||||
void al_foreach( array_list_t *l, void (*func)( void * ));
|
||||
|
||||
/**
|
||||
Same as al_foreach, but the function func takes an additional
|
||||
argument, which is provided by the caller in the variable aux
|
||||
*/
|
||||
void al_foreach2( array_list_t *l, void (*func)(const void *, void *), void *aux);
|
||||
void al_foreach2( array_list_t *l, void (*func)( void *, void *), void *aux);
|
||||
|
||||
/**
|
||||
Compares two wide character strings without case but with
|
||||
|
|
Loading…
Reference in a new issue