Re: [PATCH v7 4/4] cat-file: add --batch-command mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Cai <johncai86@xxxxxxxxx> writes:

> Yeah, this is what I had before but there was discussion about
> separation of concerns in [1]. But perhaps it's preferable
> compared to passing a pointer to nr.

Oh, I see.

I do not see any issue with separation of concerns here, actually.

As long as "dispatch_calls() consumes all the cmd[] before it
returns to the caller" is clearly understood between the function
and its caller(s) [*], clearing of "nr" the caller has is entirely
caller's problem.  It becomes needed only because this caller
decides to reuse cmd[] array.

	Side note: you do have a comment before the function to tell
	what to expect out of the helper for its callers, right?

If it were just "accumulate many cmd[] and call the function once"
caller, it would care to maintain the correct "nr" only up to the
point where the function is called (because <cmd[], nr> pair is the
way the function takes the list of commands and it needs a correct
"nr"), but not after making the call, as the only thing left to do
would be to free the cmd[] array itself, which does not even need
"nr".




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux