Skip to content

Commit

Permalink
Teach notes code to free its internal data structures on request
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Herland authored and Junio C Hamano committed Oct 20, 2009
1 parent 8b208f0 commit 27d5756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ static unsigned char *lookup_notes(const unsigned char *commit_sha1)
return hash_map.entries[index].notes_sha1;
}

void free_notes(void)
{
free(hash_map.entries);
memset(&hash_map, 0, sizeof(struct hash_map));
initialized = 0;
}

void get_commit_notes(const struct commit *commit, struct strbuf *sb,
const char *output_encoding, int flags)
{
Expand Down
3 changes: 3 additions & 0 deletions notes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef NOTES_H
#define NOTES_H

/* Free (and de-initialize) the internal notes tree structure */
void free_notes(void);

#define NOTES_SHOW_HEADER 1
#define NOTES_INDENT 2

Expand Down

0 comments on commit 27d5756

Please sign in to comment.