Skip to content

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Sep 12, 2025


Revisions:

v2
  • Copy the structure at once.
$ git range-diff shadow/master gh/lor lor
-:  -------- > 1:  e5fa846c lib/subordinateio.c: append_range(): Copy the entire structure at once
1:  bbdb4e69 ! 2:  653d825f lib/subordinateio.c: Use REALLOCF() instead of its pattern
    @@ lib/subordinateio.c: static bool have_range(struct commonio_db *db,
     +  if (!*ranges)
                return false;
      
    --  sr[n].start = new->start;
    --  sr[n].count = new->count;
    +-  sr[n] = *new;
     -  *ranges = sr;
    -+  (*ranges)[n].start = new->start;
    -+  (*ranges)[n].count = new->count;
    ++  (*ranges)[n] = *new;
      
        return true;
      }
2:  292d9fe4 ! 3:  a8b7a924 lib/subordinateio.c: append_range(): Use reallocf(3)-like calling conventions
    @@ lib/subordinateio.c: static const struct subordinate_range *find_range(struct co
     +  if (ranges == NULL)
     +          return NULL;
      
    --  (*ranges)[n].start = new->start;
    --  (*ranges)[n].count = new->count;
    -+  ranges[n].start = new->start;
    -+  ranges[n].count = new->count;
    +-  (*ranges)[n] = *new;
    ++  ranges[n] = *new;
      
     -  return true;
     +  return ranges;
v2b
  • Revert v2.
$ git range-diff shadow/master gh/lor lor 
1:  e5fa846c < -:  -------- lib/subordinateio.c: append_range(): Copy the entire structure at once
2:  653d825f ! 1:  bbdb4e69 lib/subordinateio.c: Use REALLOCF() instead of its pattern
    @@ lib/subordinateio.c: static bool have_range(struct commonio_db *db,
     +  if (!*ranges)
                return false;
      
    --  sr[n] = *new;
    +-  sr[n].start = new->start;
    +-  sr[n].count = new->count;
     -  *ranges = sr;
    -+  (*ranges)[n] = *new;
    ++  (*ranges)[n].start = new->start;
    ++  (*ranges)[n].count = new->count;
      
        return true;
      }
3:  a8b7a924 ! 2:  292d9fe4 lib/subordinateio.c: append_range(): Use reallocf(3)-like calling conventions
    @@ lib/subordinateio.c: static const struct subordinate_range *find_range(struct co
     +  if (ranges == NULL)
     +          return NULL;
      
    --  (*ranges)[n] = *new;
    -+  ranges[n] = *new;
    +-  (*ranges)[n].start = new->start;
    +-  (*ranges)[n].count = new->count;
    ++  ranges[n].start = new->start;
    ++  ranges[n].count = new->count;
      
     -  return true;
     +  return ranges;
v2c
  • Rebase
$ git range-diff bbdb4e69b161^..292d9fe404a4 shadow/master..lor 
1:  bbdb4e69 = 1:  e2fd8cb6 lib/subordinateio.c: Use REALLOCF() instead of its pattern
2:  292d9fe4 = 2:  b9f45df1 lib/subordinateio.c: append_range(): Use reallocf(3)-like calling conventions

…ventions

By returning the new pointer, we can simplify the implementation,
and we avoid a return-by-parameter.

Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant