From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH 11/15] builtin/check-attr: fix a memleak
Date: Fri, 20 Mar 2015 17:28:08 -0700 [thread overview]
Message-ID: <1426897692-18322-12-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1426897692-18322-1-git-send-email-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Notes:
I do not quite recall a discussion about such fixes
when I started doing these fixes like 2 years ago.
As this is a main function of a subcommand the freed
memory is likely to have no impact as the process
is done soon, so then it gets freed by the OS which
is likey to be faster as the OS frees the whole pages
of the process. Also there is no expected memory
shortage as the process is going to be done soon
as opposed to fixing mem leaks early in the process.
An upside of fixes like this one is however to make
code analysis tools produce less noise, so narrowing
down the *real* issue may be easier.
I wonder if we could have a 'weak' free which does
nothing if git is compiled regularly and actually
frees the memory if it is build with a flag to tell
it to do so. This would help finding the real issues
as the noise goes down and it would still be 'fast'
as it could be when compiled for productive use.
On the other hand I don't like to have another
'invented here again' systemcall-ish function as
it would clutter the code and you'd have to remember
to use that weak free.
I dunno.
builtin/check-attr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 21d2bed..fa96356 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -182,5 +182,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
check_attr(prefix, cnt, check, argv[i]);
maybe_flush_or_die(stdout, "attribute to stdout");
}
+
+ free(check);
return 0;
}
--
2.3.0.81.gc37f363
next prev parent reply other threads:[~2015-03-21 0:28 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-21 0:27 [PATCH 00/15] Fixing memory leaks Stefan Beller
2015-03-21 0:27 ` [PATCH 01/15] read-cache: fix memleak Stefan Beller
2015-03-21 3:26 ` Junio C Hamano
2015-03-23 16:24 ` Stefan Beller
2015-03-23 17:57 ` [PATCH 1/2] " Stefan Beller
2015-03-23 17:57 ` [PATCH 2/2] read-cache.c: fix a memleak in add_to_index Stefan Beller
2015-03-23 18:07 ` Junio C Hamano
2015-03-23 18:11 ` [PATCH 1/2] read-cache: fix memleak Junio C Hamano
2015-03-21 0:27 ` [PATCH 02/15] read-cache: Improve readability Stefan Beller
2015-03-21 4:19 ` Junio C Hamano
2015-03-21 5:11 ` Stefan Beller
2015-03-22 19:26 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 03/15] read-cache: free cache entry in add_to_index in case of early return Stefan Beller
2015-03-21 3:31 ` Junio C Hamano
2015-03-21 5:10 ` Stefan Beller
2015-03-22 19:11 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 04/15] update-index: fix a memleak Stefan Beller
2015-03-21 3:40 ` Junio C Hamano
2015-03-23 16:53 ` [PATCH] update-index: Don't copy memory around Stefan Beller
2015-03-23 17:11 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 05/15] builtin/apply.c: fix a memleak Stefan Beller
2015-03-21 3:45 ` Junio C Hamano
2015-03-23 17:13 ` [PATCH] builtin/apply.c: fix a memleak (Fixup, squashable) Stefan Beller
2015-03-23 17:27 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 06/15] merge-blobs.c: Fix a memleak Stefan Beller
2015-03-21 0:28 ` [PATCH 07/15] merge-recursive: fix memleaks Stefan Beller
2015-03-21 3:48 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 08/15] http-push: Remove unneeded cleanup Stefan Beller
2015-03-21 0:28 ` [PATCH 09/15] http: release the memory of a http pack request as well Stefan Beller
2015-03-22 19:36 ` Junio C Hamano
2015-03-24 16:54 ` Stefan Beller
2015-03-24 17:48 ` Junio C Hamano
2015-03-21 0:28 ` [PATCH 10/15] commit.c: fix a memory leak Stefan Beller
2015-03-21 3:59 ` Junio C Hamano
2015-03-24 13:42 ` Duy Nguyen
2015-03-24 21:17 ` Re* " Junio C Hamano
2015-03-24 21:20 ` Stefan Beller
2015-03-21 0:28 ` Stefan Beller [this message]
2015-03-21 4:02 ` [PATCH 11/15] builtin/check-attr: fix a memleak Junio C Hamano
2015-03-21 0:28 ` [PATCH 12/15] builtin/merge-base: fix memleak Stefan Beller
2015-03-21 0:28 ` [PATCH 13/15] builtin/unpack-file: fix a memleak Stefan Beller
2015-03-21 0:28 ` [PATCH 14/15] builtin/cat-file: free memleak Stefan Beller
2015-03-21 0:28 ` [PATCH 15/15] ls-files: fix a memleak Stefan Beller
2015-03-21 3:21 ` [PATCH 00/15] Fixing memory leaks 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=1426897692-18322-12-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).