This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Tom Tromey <tromey at redhat dot com>, Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- Date: Wed, 13 Nov 2013 09:01:37 +0100
- Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
- Authentication-results: sourceware.org; auth=none
- References: <DUB122-W32B887B9B78C252A2B9146E40B0 at phx dot gbl> <20131031144309 dot GR27813 at tucnak dot zalov dot cz> <87y559xz7y dot fsf at redhat dot com> <20131031173649 dot GW27813 at tucnak dot zalov dot cz> <87zjpbb5qu dot fsf at redhat dot com> <20131111142159 dot GZ27813 at tucnak dot zalov dot cz> <878uwuap4f dot fsf at redhat dot com> <878uwt63e2 dot fsf at redhat dot com> <DUB122-W11E7FE6263E9AF426B4F90E4FE0 at phx dot gbl> <877gcc4vzs dot fsf at redhat dot com> <DUB122-W41103324C30066CF0AA665E4F90 at phx dot gbl>
Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
>>> 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 -- in *line_len = --len;
Sorry, I don't see how that is an issue. This looks like a classical
way of passing an output parameter to me.
> 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 ?
I thought about avoiding the copying of course. But the issue with that
is that that ties the lifetime of the returned line to the time between
two invocations of read_next_line. IOW, you'd have to use the line
"quickly" before calling read_next_line again. Actually that
non-copying API that you are talking about exists in the patch; it's
get_next_line. And you see that it's what we use when we want to avoid
the copying, e.g, in goto_next_line. But when we want to give the
"final" user the string, I believe that copying is less surprising. And
from what I could see from the tests I have done, the copying doesn't
make the thing slower than without the patch. So I'd like to keep this
unless folks have very strong feeling about it.
--
Dodji