* Re: [pph] Fixing string streaming functions and their comments (issue4654076)
@ 2011-06-30 13:31 dnovillo
0 siblings, 0 replies; 2+ messages in thread
From: dnovillo @ 2011-06-30 13:31 UTC (permalink / raw)
To: gchare, crowl; +Cc: gcc-patches, reply
On 2011/06/30 01:37:59, Gabriel Charette wrote:
> 2011-06-29 Gabriel Charette <mailto:gchare@google.com>
> * pph-streamer.h (struct pph_stream): Fix comment of data_in field.
> (pph_out_string_with_length): lto_output_string_with_length now
handles
> NULL strings, call it directly.
> (pph_in_string): Fix comment.
OK.
Diego.
http://codereview.appspot.com/4654076/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pph] Fixing string streaming functions and their comments (issue4654076)
@ 2011-06-30 9:13 Gabriel Charette
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Charette @ 2011-06-30 9:13 UTC (permalink / raw)
To: reply, crowl, dnovillo, gcc-patches
Some comments were wrong.
In particular, the strings read from the stream are placed in a data table, and thus the strings returned DO NOT need to be freed by the caller, they belong to the stream who handles them itself.
Also lto_output_string_with_length does handle NULL strings, removed the redundant logic.
Tested with bootstrap build and pph regression testing.
2011-06-29 Gabriel Charette <gchare@google.com>
* pph-streamer.h (struct pph_stream): Fix comment of data_in field.
(pph_out_string_with_length): lto_output_string_with_length now handles
NULL strings, call it directly.
(pph_in_string): Fix comment.
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index b899501..8d0c024 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -100,7 +100,7 @@ typedef struct pph_stream {
struct lto_input_block *ib;
/* String tables and other descriptors used by the LTO reading
- routines. NULL when the file is opened for reading. */
+ routines. NULL when the file is opened for writing. */
struct data_in *data_in;
/* Array of sections in the PPH file. */
@@ -250,21 +250,10 @@ static inline void
pph_out_string_with_length (pph_stream *stream, const char *str,
unsigned int len)
{
- if (str)
- {
- if (flag_pph_tracer >= 4)
- pph_trace_string_with_length (stream, str, len);
- lto_output_string_with_length (stream->ob, stream->ob->main_stream,
- str, len + 1, false);
- }
- else
- {
- /* lto_output_string_with_length does not handle NULL strings,
- but lto_output_string does. */
- if (flag_pph_tracer >= 4)
- pph_trace_string (stream, str);
- pph_out_string (stream, NULL);
- }
+ if (flag_pph_tracer >= 4)
+ pph_trace_string_with_length (stream, str, len);
+ lto_output_string_with_length (stream->ob, stream->ob->main_stream,
+ str, len + 1, false);
}
/* Output VEC V of ASTs to STREAM.
@@ -338,9 +327,7 @@ pph_in_bytes (pph_stream *stream, void *p, size_t n)
pph_trace_bytes (stream, p, n);
}
-/* Read and return a string of up to MAX characters from STREAM.
- The caller is responsible for freeing the memory allocated
- for the string. */
+/* Read and return a string of up to MAX characters from STREAM. */
static inline const char *
pph_in_string (pph_stream *stream)
--
This patch is available for review at http://codereview.appspot.com/4654076
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-30 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 13:31 [pph] Fixing string streaming functions and their comments (issue4654076) dnovillo
-- strict thread matches above, loose matches on Subject: below --
2011-06-30 9:13 Gabriel Charette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).