Re: [PATCH] mailsplit and mailinfo: gracefully handle NUL characters | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
"Brian Foster" <brian.foster@xxxxxxxxxxxxxxx> writes:
> I'd tend to write this in terms of pointers,
> something along the lines (untested):
>
> char *p, *endp;
>
> assert(1 <= size);
> p = buf;
> endp = p + (size-1);
> while (p < endp) {
> if ((c = getc(in)) == EOF || (*p++ = c) == '\n')
> break;
> }
> *p = '\0';
>
> return p - buf;
Leave optimization to the compiler. Using pointer arithmetic more often
than not screws up loop optimization and strength reduction.
--
David Kastrup
--
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
[Newbies FAQ] [Kernel List] [Site Home] [Free Online Dating] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Free Online Dating] [Rubini] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [DDR & Rambus] [Linux Resources]