mirror of
https://gitee.com/lionsoul/friso.git
synced 2024-12-02 03:07:52 +08:00
fix two memory leak.
This commit is contained in:
parent
ff08d3d261
commit
702453b148
@ -1312,7 +1312,7 @@ FRISO_API friso_hits_t friso_next(
|
||||
string_buffer_t sb = NULL;
|
||||
lex_entry_t lex = NULL, tmp = NULL, sword = NULL;
|
||||
|
||||
/* {{{ task buffer check */
|
||||
/* {{{ task word pool check */
|
||||
if ( ! link_list_empty( task->pool ) ) {
|
||||
/*
|
||||
* load word from the word poll if it is not empty.
|
||||
|
@ -337,7 +337,7 @@ FRISO_API void free_hash_table( friso_hash_t, fhash_callback_fn_t );
|
||||
* ----------------------------------------
|
||||
* the function associates the specified key with the given value.
|
||||
*/
|
||||
FRISO_API void hash_put_mapping( friso_hash_t, fstring, void * );
|
||||
FRISO_API void *hash_put_mapping( friso_hash_t, fstring, void * );
|
||||
|
||||
/*
|
||||
* Function: is_mapping_exists
|
||||
|
@ -188,13 +188,14 @@ FRISO_API void free_hash_table(
|
||||
|
||||
//put a new mapping insite.
|
||||
//the value cannot be NULL.
|
||||
FRISO_API void hash_put_mapping(
|
||||
FRISO_API void *hash_put_mapping(
|
||||
friso_hash_t _hash,
|
||||
fstring key,
|
||||
void * value )
|
||||
{
|
||||
uint_t bucket = ( key == NULL ) ? 0 : hash( key, _hash->length );
|
||||
hash_entry_t e = *( _hash->table + bucket );
|
||||
void *oval = NULL;
|
||||
|
||||
//check the given key is already exists or not.
|
||||
for ( ; e != NULL; e = e->_next )
|
||||
@ -203,8 +204,9 @@ FRISO_API void hash_put_mapping(
|
||||
|| ( key != NULL && e->_key != NULL
|
||||
&& strcmp( key, e->_key ) == 0 ) )
|
||||
{
|
||||
oval = e->_val; //bak the old value
|
||||
e->_val = value;
|
||||
return;
|
||||
return oval;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +218,7 @@ FRISO_API void hash_put_mapping(
|
||||
if ( _hash->size >= _hash->threshold )
|
||||
rebuild_hash( _hash );
|
||||
|
||||
return oval;
|
||||
}
|
||||
|
||||
//check the existence of the mapping associated with the given key.
|
||||
|
@ -51,6 +51,10 @@ __STATIC_API__ void default_fdic_callback( hash_entry_t e )
|
||||
}
|
||||
free_array_list( syn );
|
||||
}
|
||||
|
||||
//free the e->_val
|
||||
//@date 2014-01-28 posted by mlemay@gmail.com
|
||||
FRISO_FREE(lex);
|
||||
}
|
||||
|
||||
FRISO_API void friso_dic_free( friso_dic_t dic )
|
||||
@ -300,7 +304,11 @@ FRISO_API void friso_dic_load(
|
||||
* and __LEX_CEM_WORDS__.
|
||||
*/
|
||||
if ( ! ( lex == __LEX_ECM_WORDS__ || lex == __LEX_CEM_WORDS__ )
|
||||
&& strlen( _word ) > length ) continue;
|
||||
&& strlen( _word ) > length )
|
||||
{
|
||||
FRISO_FREE(_word);
|
||||
continue;
|
||||
}
|
||||
|
||||
//2. get the synonyms words.
|
||||
_syn = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user