Thread (4 messages) flat view 4 messages, 2 authors, 2017-08-23

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

From: Brandon Casey <hidden>
Date: 2017-08-23 21:55:06

Possibly related (same subject, not in this thread)

On Wed, Aug 23, 2017 at 2:20 PM, Brandon Casey [off-list ref] wrote:
On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano [off-list ref] wrote:
quoted
Brandon Casey [off-list ref] writes:
quoted
So is there any reason why didn't do something like the following in
the first place?
My guess is that we didn't bother; if we cared, we would have used a
single instance of const char in a read-only segment, instead of
such a macro.
I think you mean something like this:

   const char * const strbuf_slopbuf = "";
Ah, you probably meant something like this:

   const char strbuf_slopbuf = '\0';

which gcc will apparently place in the read-only segment.  I did not know that.

And assignment and initialization would look like:

   sb->buf = (char*) &strbuf_slopbuf;

and

   #define STRBUF_INIT  { .alloc = 0, .len = 0, .buf = (char*) &strbuf_slopbuf }

respectively.  Yeah, that's definitely preferable to a macro.
Something similar could be done in object.c.

-Brandon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help