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

Re: [PATCH 1/2] add MOVE_ARRAY

From
Jeff King <peff@peff.net>
Date
Jul 16, 2017, 10:31 UTC
Message-ID
<20170716103132.z36audbi7wxot7e6@sigill.intra.peff.net>
In-Reply-To
<ec78a849-36e4-4b1d-1ad6-46dcc39a1396@web.de>
On Sat, Jul 15, 2017 at 09:36:20PM +0200, René Scharfe wrote:
Show 8 quoted lines
> Similar to COPY_ARRAY (introduced in 60566cbb58), add a safe and
> convenient helper for moving potentially overlapping ranges of array
> entries.  It infers the element size, multiplies automatically and
> safely to get the size in bytes, does a basic type safety check by
> comparing element sizes and unlike memmove(3) it supports NULL
> pointers iff 0 elements are to be moved.
> 
> Also add a semantic patch to demonstrate the helper's intended usage.

If we have COPY_ARRAY(), I think it's foolish not to provide the matching MOVE_ARRAY(). If it were just the "if (n)", I might say we could just do this inline in the few calls that care. But I really like the size safety.

I agree with your comments elsewhere that we don't need to worry about the case where one of the arrays is NULL but the size is not zero. That's a flat-out bug.

-Peff
Previous: René Scharfe
Message 6 of 6 in “add MOVE_ARRAY”
  1. 1/2 add MOVE_ARRAYRené Scharfe, Jul 15, 2017
  2. 2/2 use MOVE_ARRAYRené Scharfe, Jul 15, 2017
  3. 3/2 apply: use COPY_ARRAY and MOVE_ARRAY in update_image()René Scharfe, Jul 15, 2017
  4. Ramsay JonesJul 16, 2017
  5. René ScharfeJul 16, 2017
  6. Jeff KingJul 16, 2017

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.