Teach notes code to free its internal data structures on request
There's no need to be rude to memory-concious callers... This patch has been improved by the following contributions: - Junio C Hamano: avoid old-style declaration Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johan Herland committed
Oct 9, 2009 at 12:22 UTC
27d57564102a98950bf4398daeeb14a15154478f
2 files changed
+10
notes.c
+7
@@ -105,6 +105,13 @@ static unsigned char *lookup_notes(const unsigned char *commit_sha1)
105
return hash_map.entries[index].notes_sha1;
106
}
107
108
+void free_notes(void)
109
+{
110
+ free(hash_map.entries);
111
+ memset(&hash_map, 0, sizeof(struct hash_map));
112
+ initialized = 0;
113
+}
114
+
115
void get_commit_notes(const struct commit *commit, struct strbuf *sb,
116
const char *output_encoding, int flags)
117
{
notes.h
+3
@@ -1,6 +1,9 @@
1
#ifndef NOTES_H
2
#define NOTES_H
3
4
+/* Free (and de-initialize) the internal notes tree structure */
5
+void free_notes(void);
6
+
7
#define NOTES_SHOW_HEADER 1
8
#define NOTES_INDENT 2
9