From: Heiko Voigt <hvoigt@hvoigt.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jens Lehmann <jens.lehmann@web.de>,
Jonathan Nieder <jrnieder@gmail.com>, Jeff King <peff@peff.net>
Subject: [PATCH 1/5] hashmap: add enum for hashmap free_entries option
Date: Thu, 5 Jun 2014 08:06:40 +0200 [thread overview]
Message-ID: <20140605060640.GB23874@sandbox-ub> (raw)
In-Reply-To: <20140605060425.GA23874@sandbox-ub>
This allows a reader to immediately know which options can be used and
what this parameter is about.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
Documentation/technical/api-hashmap.txt | 2 +-
diffcore-rename.c | 2 +-
hashmap.c | 2 +-
hashmap.h | 8 +++++++-
name-hash.c | 4 ++--
test-hashmap.c | 6 +++---
6 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/Documentation/technical/api-hashmap.txt b/Documentation/technical/api-hashmap.txt
index b977ae8..b04bb40 100644
--- a/Documentation/technical/api-hashmap.txt
+++ b/Documentation/technical/api-hashmap.txt
@@ -187,7 +187,7 @@ void long2double_init(void)
void long2double_free(void)
{
- hashmap_free(&map, 1);
+ hashmap_free(&map, HASHMAP_FREE_ENTRIES);
}
static struct long2double *find_entry(long key)
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 749a35d..f30239a 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -335,7 +335,7 @@ static int find_exact_renames(struct diff_options *options)
renames += find_identical_files(&file_table, i, options);
/* Free the hash data structure and entries */
- hashmap_free(&file_table, 1);
+ hashmap_free(&file_table, HASHMAP_FREE_ENTRIES);
return renames;
}
diff --git a/hashmap.c b/hashmap.c
index d1b8056..9a3555a 100644
--- a/hashmap.c
+++ b/hashmap.c
@@ -135,7 +135,7 @@ void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
alloc_table(map, size);
}
-void hashmap_free(struct hashmap *map, int free_entries)
+void hashmap_free(struct hashmap *map, enum hashmap_free_options free_entries)
{
if (!map || !map->table)
return;
diff --git a/hashmap.h b/hashmap.h
index a816ad4..6c558df 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -1,6 +1,11 @@
#ifndef HASHMAP_H
#define HASHMAP_H
+enum hashmap_free_options {
+ HASHMAP_NO_FREE_ENTRIES = 0,
+ HASHMAP_FREE_ENTRIES = 1,
+};
+
/*
* Generic implementation of hash-based key-value mappings.
* See Documentation/technical/api-hashmap.txt.
@@ -39,7 +44,8 @@ struct hashmap_iter {
extern void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
size_t initial_size);
-extern void hashmap_free(struct hashmap *map, int free_entries);
+extern void hashmap_free(struct hashmap *map,
+ enum hashmap_free_options free_entries);
/* hashmap_entry functions */
diff --git a/name-hash.c b/name-hash.c
index 97444d0..be7c4ae 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -233,6 +233,6 @@ void free_name_hash(struct index_state *istate)
return;
istate->name_hash_initialized = 0;
- hashmap_free(&istate->name_hash, 0);
- hashmap_free(&istate->dir_hash, 1);
+ hashmap_free(&istate->name_hash, HASHMAP_NO_FREE_ENTRIES);
+ hashmap_free(&istate->dir_hash, HASHMAP_FREE_ENTRIES);
}
diff --git a/test-hashmap.c b/test-hashmap.c
index f5183fb..ac8d6a2 100644
--- a/test-hashmap.c
+++ b/test-hashmap.c
@@ -100,7 +100,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
hashmap_add(&map, entries[i]);
}
- hashmap_free(&map, 0);
+ hashmap_free(&map, HASHMAP_NO_FREE_ENTRIES);
}
} else {
/* test map lookups */
@@ -121,7 +121,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
}
}
- hashmap_free(&map, 0);
+ hashmap_free(&map, HASHMAP_NO_FREE_ENTRIES);
}
}
@@ -250,6 +250,6 @@ int main(int argc, char *argv[])
}
}
- hashmap_free(&map, 1);
+ hashmap_free(&map, HASHMAP_FREE_ENTRIES);
return 0;
}
--
2.0.0
next prev parent reply other threads:[~2014-06-05 6:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 6:04 [PATCH 0/5] submodule config lookup API Heiko Voigt
2014-06-05 6:06 ` Heiko Voigt [this message]
2014-06-06 17:52 ` [PATCH 1/5] hashmap: add enum for hashmap free_entries option Karsten Blees
2014-06-10 10:17 ` Heiko Voigt
2014-06-11 9:12 ` Karsten Blees
2014-06-12 19:12 ` Junio C Hamano
2014-06-17 8:30 ` Karsten Blees
2014-06-17 19:04 ` Heiko Voigt
2014-06-17 22:19 ` Junio C Hamano
2014-06-05 6:07 ` [PATCH 2/5] implement submodule config cache for lookup of submodule names Heiko Voigt
2014-06-05 17:46 ` W. Trevor King
2014-06-06 5:20 ` Heiko Voigt
2014-06-08 9:04 ` Eric Sunshine
2014-06-10 10:19 ` Heiko Voigt
2014-06-12 21:58 ` Junio C Hamano
2014-06-13 22:37 ` Heiko Voigt
2014-06-05 6:08 ` [PATCH 3/5] extract functions for submodule config set and lookup Heiko Voigt
2014-06-05 6:09 ` [PATCH 4/5] use new config API for worktree configurations of submodules Heiko Voigt
2014-06-05 6:09 ` [PATCH 5/5] do not die on error of parsing fetchrecursesubmodules option Heiko Voigt
2014-06-12 21:59 ` [PATCH 0/5] submodule config lookup API Junio C Hamano
2014-06-13 22:41 ` Heiko Voigt
2014-06-16 17:58 ` Junio C Hamano
2014-06-17 19:00 ` Heiko Voigt
2014-06-12 22:04 ` Junio C Hamano
2014-06-13 7:13 ` Jens Lehmann
2014-06-13 17:50 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140605060640.GB23874@sandbox-ub \
--to=hvoigt@hvoigt.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jens.lehmann@web.de \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).