rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 2e2faaeb89023bdfde43ae0104db1b95e2309691
parent 7c3c83776663d81473f02c40d3ff82aec53dbe15
Author: vaplv <vaplv@free.fr>
Date:   Wed, 18 Jun 2014 16:32:32 +0200

Fix typos

Diffstat:
Msrc/hash_table.h | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/hash_table.h b/src/hash_table.h @@ -164,6 +164,7 @@ static INLINE void HTABLE_FUNC__(pair_init__) (struct mem_allocator* allocator, struct HTABLE_PAIR__* pair) { + ASSERT(pair); HTABLE_KEY_FUNCTOR_INIT(allocator, &pair->key); HTABLE_DATA_FUNCTOR_INIT(allocator, &pair->data); } @@ -171,6 +172,7 @@ HTABLE_FUNC__(pair_init__) static INLINE void HTABLE_FUNC__(pair_release__)(struct HTABLE_PAIR__* pair) { + ASSERT(pair); HTABLE_KEY_FUNCTOR_RELEASE(&pair->key); HTABLE_DATA_FUNCTOR_RELEASE(&pair->data); } @@ -180,6 +182,7 @@ HTABLE_FUNC__(pair_copy__) (struct HTABLE_PAIR__* dst, struct HTABLE_PAIR__ const* src) { int res = 0; + ASSERT(dst && src); if((res = HTABLE_KEY_FUNCTOR_COPY(&dst->key, &src->key))) return res; res = HTABLE_DATA_FUNCTOR_COPY(&dst->data, &src->data); @@ -191,6 +194,7 @@ HTABLE_FUNC__(pair_copy_and_release__) (struct HTABLE_PAIR__* dst, struct HTABLE_PAIR__* src) { int res = 0; + ASSERT(dst && src); if((res = HTABLE_KEY_FUNCTOR_COPY_AND_RELEASE(&dst->key, &src->key))) return res; res = HTABLE_DATA_FUNCTOR_COPY_AND_RELEASE(&dst->data, &src->data); @@ -277,7 +281,7 @@ HTABLE_FUNC__(clear)(struct HTABLE__* htbl) FOR_EACH(islot, 0, HTABLE_DATA_FUNC__(size_get)(&htbl->table)) { struct HTABLE_PAIR__* pair = NULL; if(in_use == htbl->table_size_in_use) - break; /* Early stop the rehasing since there is no more slot in htbl */ + break; /* Early stop the clear since there is no more slot in htbl */ if(!darray_char_cdata_get(&htbl->table_slot_is_used)[islot]) continue; @@ -317,8 +321,8 @@ HTABLE_FUNC__(reserve)(struct HTABLE__* htbl, const size_t size_submitted) int res = 0; ASSERT(htbl); - size = round_up_pow2( size_submitted ); - if( size <= HTABLE_DATA_FUNC__(size_get)(&htbl->table)) + size = round_up_pow2(size_submitted); + if(size <= HTABLE_DATA_FUNC__(size_get)(&htbl->table)) goto exit; HTABLE_DATA_FUNC__(init)(htbl->allocator, &tbl); @@ -420,7 +424,7 @@ HTABLE_FUNC__(erase)(struct HTABLE__* htbl, HTABLE_KEY const* key) size_t i = 0, j = 0, tbl_size = 0; struct HTABLE_PAIR__* pairs = NULL; char* used_pairs = NULL; - ASSERT(htbl && key ); + ASSERT(htbl && key); pairs = HTABLE_DATA_FUNC__(data_get)(&htbl->table); tbl_size = HTABLE_DATA_FUNC__(size_get)(&htbl->table); @@ -437,7 +441,7 @@ HTABLE_FUNC__(erase)(struct HTABLE__* htbl, HTABLE_KEY const* key) for(j = (i + 1) & (tbl_size - 1); /* <=> j = (i+1) % size */ used_pairs[j]; - j = (j + 1) & (tbl_size - 1) ) { /* <=> j = (j+1) % size */ + j = (j + 1) & (tbl_size - 1)) { /* <=> j = (j+1) % size */ const size_t k = HTABLE_KEY_FUNCTOR_HASH(&pairs[j].key) & (tbl_size- 1); if(i <= j ? (i < k && k <= j) : (i < k || k <= j)) @@ -577,5 +581,8 @@ HTABLE_FUNC__(iterator_data_get)(const struct HTABLE_ITERATOR__* it) #undef HTABLE_ITERATOR__ #undef HTABLE_FUNC__ +#undef HTABLE_DATA__ +#undef HTABLE_DATA_FUNC__ + #endif /* !HTABLE_NAME || !HTABLE_KEY || !HTABLE_DATA */