[Patch, libgfortran] Remove small_buffer, unneccessary buffer for internal I/O

Jerry DeLisle jvdelisle@verizon.net
Thu May 24 13:57:00 GMT 2007


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



More information about the Fortran mailing list