This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/6] New function null_stream

On 01/18/2017 09:18 AM, Simon Marchi wrote:
On 2017-01-18 10:01, Luis Machado wrote:
On 01/18/2017 08:57 AM, Simon Marchi wrote:
On 2017-01-18 09:53, Luis Machado wrote:
We're setting stream to NULL at the top of the function and then
checking if it is NULL (it obviously is) right after that? Am i
missing something?

The "static" :).

Oh, that's what i was missing!

Can't we have a clearer way of reusing this stream? It looks cryptic
this way (at least i think it looks cryptic).

With Pedro's ui_file c++ification series, there is a null_file
specialization of ui_file, and it's just a global object that you can

Search for "null_file null_stream" in

That is perfectly fine. The cryptic bit i was referring to was declaring/initializing a static variable inside this particular function.

It ought to be possible to initialize the static variable somewhere else and only do the null check/allocation in the function? Compilers will often zero these out too, so initializing to NULL may not even be needed?

The fact that the initialization only happens once but the source line is there forever can cause some confusion.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]