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

Re: [PATCH maint] builtin-merge.c: fix memory under-allocation

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Oct 9, 2008, 00:27 UTC
Message-ID
<0LPLRUZaEHuEZTri_v38ySJHqYAhrfOpOkyUviUH9eOrx8IXBEAzYA@cipher.nrlssc.navy.mil>
In-Reply-To
<20081009001727.GP536@genesis.frugalware.org>
Miklos Vajna wrote:
Show 7 quoted lines
> On Wed, Oct 08, 2008 at 07:07:54PM -0500, Brandon Casey <casey@nrlssc.navy.mil> wrote:
>> While we're at it, change the allocation to reference the variable it is
>> allocating memory for to try to prevent a similar mistake if the type is
>> changed in the future.
> 
> If this is really a problem, then I think it would be good to mention
> this in Documentation/CodingGuidelines.

That's fine. Though I didn't mean to imply that the memory under-allocation was caused by a change in variable type in this case. Re-reading my commit message, maybe it sounds like that.

  Something like this sometimes happens:
-    struct a_struct *foo = xmalloc(sizeof(struct a_struct));
+    struct a_bigr_struct *foo = xmalloc(sizeof(struct a_struct));
  which would be avoided if we had started with:
     struct a_struct *foo = xmalloc(sizeof(*foo));
-brandon
Previous: Miklos VajnaNext: Junio C Hamano
Message 3 of 7 in “builtin-merge.c: fix memory under-allocation”
  1. builtin-merge.c: fix memory under-allocationBrandon Casey, Oct 9, 2008
  2. Miklos VajnaOct 9, 2008
  3. Brandon CaseyOct 9, 2008
  4. Junio C HamanoOct 9, 2008
  5. Brandon CaseyOct 9, 2008
  6. Miklos VajnaOct 9, 2008
  7. Shawn O. PearceOct 9, 2008

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.