Thread (7 messages) flat view 7 messages, 5 authors, 2016-06-15

Re: [PATCH] hash: Remove useless init_hash()

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:11

On Tue, Jul 27, 2010 at 10:30, Jakub Narebski [off-list ref] wrote:

CC-ing Linus since he wrote it (per Documentation/SubmittingPatches).
Stephen Boyd [off-list ref] writes:
quoted
init_hash() is essentially a memset() so just use that.

Signed-off-by: Stephen Boyd <redacted>
[...]

Encapsulation is good.

[..]

This is IMHO slightly less readable, and doesn't protect against
changes in implementation.
Agreed.
quoted
      for (i = 0; i < rename_src_nr; i++)
              insert_file_table(&file_table, -1, i, rename_src[i].one);
diff --git a/hash.h b/hash.h
index 69e33a4..418be24 100644
--- a/hash.h
+++ b/hash.h
@@ -33,11 +33,4 @@ extern void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table
 extern int for_each_hash(const struct hash_table *table, int (*fn)(void *));
 extern void free_hash(struct hash_table *table);

-static inline void init_hash(struct hash_table *table)
-{
-     table->size = 0;
-     table->nr = 0;
-     table->array = NULL;
-}
*This* could be replaced by memset.
No it couldn't? The second argument to memset is just an int, so
setting the memory area to 0 isn't portable to systems where the
representation of NULL isn't "0".

(It's early so I may be misremembering my C..)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help