Re: [PATCH] blame.c: prepare_lines should not call xrealloc for every line

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

 



David Kastrup <dak@xxxxxxx> writes:

> Ok, I now wrote
>
> 	for (p = buf;; num++, p++) {
> 		p = memchr(p, '\n', end - p);
> 		if (!p)
> 			break;
> 	}

Looks still wrong (perhaps this is a taste issue).

	num++ is not "loop control", but the real action of this
	loop to count lines.  It is better left inside.

	p++ is "loop control", and belongs to the third part of
	for(;;).

	Isn't the normal continuation condition "p < end"?

so something like

	for (p = buf; p < end; p++) {
        	p = find the end of this line
                if (!p)
                	break;
		num++;
	}

perhaps?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]