bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'string-buffer'


From: Bruce Korb
Subject: Re: new module 'string-buffer'
Date: Sun, 21 Feb 2021 14:20:01 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

Hi,

On 2/21/21 12:55 PM, Bruno Haible wrote:
What alternative does gnulib offer to people who use open_memstream()?
open_memstream is not portable:
   https://www.gnu.org/software/gnulib/manual/html_node/open_005fmemstream.html
I mentioned this a couple of decades ago. There was no solution, so I rolled my own.
But gnulib cannot provide a drop-in replacement since it would require
unportable stream hackery (worse that stdio-impl.h).

The alternative is a string buffer module. Gnulib has some modules that
sound good at first sight but don't fulfil the need:

I wanted something that could act like a dropin replacement for fopen-ing a regular file. There are some quirks (if memory serves), but it is based on either fopencookie or funopen:


#ifdef HAVE_FOPENCOOKIE
        cookie_io_functions_t iof;
        iof.read  = pRd;
        iof.write = pWr;
        iof.seek  = fmem_seek;
        iof.close = fmem_close;

        res = fopencookie(pFMC, mode, iof);
#else
        res = funopen(pFMC, pRd, pWr, fmem_seek, fmem_close);
#endif

I would prefer to pull a new module and dump mine, but it needs seek and close functionality.

Attachment: fmemopen.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]