git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] get_pathspec(): free() old buffer if rewriting

From
Linus Torvalds <torvalds@osdl.org>
Date
May 6, 2006, 22:37 UTC
Message-ID
<Pine.LNX.4.64.0605061532190.16343@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.63.0605070003430.6357@wbgn013.biozentrum.uni-wuerzburg.de>
On Sun, 7 May 2006, Johannes Schindelin wrote:
> 
> This might be the wrong way to do it, but as it is without this patch,
> get_pathspec() is leaking memory.
I'm not at all convinced we want to do somethng like this.

get_pathspec() is a one-time event. It doesn't "leak" memory. To me, "leaking" is when you continually lose a bit of memory, and you eventually run out. I don't see that happening here.

It's like saying that calling an initialization routine "leaks" memory, because it doesn't free the memory that contains the function that is now no longer ever used. It's clearly leaving that memory unused, "dangling".

But the fact is, the OS will free the memory for us when we exit, and simplicity is often much more powerful than trying to be overly careful.

So there's a difference between "don't care" and "leak memory". It sounds like you may be using some automated tool that warns because it simply doesn't understand that difference.

			Linus
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 5 in “[RFC] get_pathspec(): free() old buffer if rewriting”
  1. Johannes SchindelinMay 6, 2006
  2. Linus TorvaldsMay 6, 2006
  3. Johannes SchindelinMay 6, 2006
  4. Junio C HamanoMay 7, 2006
  5. Junio C HamanoMay 7, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.