From: Ali Gholami Rudi Date: Wed, 01 Apr 2009 16:12:54 GMT Subject: Re: [PATCH] builtin-clone.c: fix memory leak in cmd_clone() Message-ID: <20090401161254.GD2237@lilem.mirepesht> In-Reply-To: Hi, Johannes Schindelin wrote: > On Wed, 1 Apr 2009, Ali Gholami Rudi wrote: > > > With this patch, cmd_clone() safely frees its xstrdup()-allocated > > memory. Also junk_work_tree and junk_git_dir (used in remove_junk() > > which is called asynchronously) were changed to use static arrays rather > > than sharing the memory allocated in cmd_clone(). > > If you want to go down that route, you will have a long way to go: the > assumption is pretty much in every cmd_() and main() function that > singletons will be free()d automatically when the process ends. Well... I saw strbuf_release() calls in the end of cmd_clone() and had a quick look at a few other cmd_*() functions; it seems most of them (?) try to free their memory. I thought it might make sense to do that for cmd_clone(). But you're right; they will be freed eventually. (It seems like a minor leak which is respected only some of the times :-) ) Regards, Ali