This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libgfortran] Remove small_buffer, unneccessary buffer for internal I/O
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 24 May 2007 06:54:01 -0700
- Subject: Re: [Patch, libgfortran] Remove small_buffer, unneccessary buffer for internal I/O
- References: <4651F810.6010102@gmail.com>
Janne Blomqvist wrote:
:ADDPATCH fortran:
Hi,
the attached patch removes usage of small_buffer in the I/O library,
instead always using a static buffer. Also, for internal units there is
no longer a buffer allocated, saving 8K (with the current BUFFER_SIZE)
of memory.
I'd be grateful if someone has an idea how to combine the identical
parts of unix_stream and int_stream, as they have to be kept in sync.
Something like
typedef struct
{
/* common parts. */
union
{
char buffer[sizeof(size_t)];
char *intbuf;
}
}
unix_stream;
would work I suppose; then when allocating a stream for external file
one would do
p = malloc (sizeof(unix_stream) + BUFFER_SIZE);
and then scribbling buffer content past the buffer array, so it's
"cheating" in a way. And the internal units would still be called
unix_stream, but they would use intbuf instead of buffer.
This patch looks good. For the common stuff, One could try to create a separate
structure for all the common items above and create two new structures.
typedef struct
{
comstream s;
char buffer[BUFFER_SIZE];
} unix_tream;
typedef struct
{
comstream s;
char * intbuf;
} intstream;
That may require a lot of editing. The patch as it is now works well.
Jerry