From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13315 invoked by alias); 13 Nov 2013 07:34:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13303 invoked by uid 89); 13 Nov 2013 07:34:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RDNS_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: dub0-omc1-s22.dub0.hotmail.com Received: from Unknown (HELO dub0-omc1-s22.dub0.hotmail.com) (157.55.0.221) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2013 07:34:12 +0000 Received: from DUB122-W41 ([157.55.0.239]) by dub0-omc1-s22.dub0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Nov 2013 23:34:03 -0800 X-TMN: [N9BxQ1ycPzZWz3Co76Ns5RnW0R8K7tMu] Message-ID: From: Bernd Edlinger To: Dodji Seketeli CC: Jakub Jelinek , GCC Patches , Tom Tromey , =?iso-8859-1?B?TWFudWVsIEzzcGV6LUli4fFleg==?= Subject: RE: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals Date: Wed, 13 Nov 2013 09:43:00 -0000 In-Reply-To: <877gcc4vzs.fsf@redhat.com> References: ,<20131031144309.GR27813@tucnak.zalov.cz> <87y559xz7y.fsf@redhat.com>,<20131031173649.GW27813@tucnak.zalov.cz> <87zjpbb5qu.fsf@redhat.com>,<20131111142159.GZ27813@tucnak.zalov.cz> <878uwuap4f.fsf@redhat.com>,<878uwt63e2.fsf@redhat.com>,,<877gcc4vzs.fsf@redhat.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg01405.txt.bz2 > >>> + memmove (*line, l, len); >>> + (*line)[len - 1] =3D '\0'; >>> + *line_len =3D --len; >> >> Generally, I would prefer to use memcpy, >> if it is clear that the memory does not overlap. > > I don't mind. I'll change that in my local copy. Thanks. > >> You copy one char too much and set it to zero? > > It's not one char too much. That char is the terminal '\n' in most > cases. > and what is it if there is no terminal '\n' ? >> Using -- on a value that goes out of scope looks >> awkward IMHO. > > I don't understand this sentence. What do you mean by "Using -- on a > value that goes out of scope"? > I meant the operator --=A0 in=A0 *line_len =3D --len; Maybe, You could also avoid the copying completely, if you just hand out a pointer to the line buffer as const char*, and use the length instead of = the nul-char as end delimiter ? Bernd.=20=09=09=20=09=20=20=20=09=09=20=20