[PATCH] Add open_wmemstream

Eric Blake ebb9@byu.net
Wed Feb 18 15:55:00 GMT 2009

Hash: SHA1

According to Corinna Vinschen on 2/17/2009 10:22 AM:
> Hi,
> I have added open_wmemstream per SUSv4 to the newlib implementation of
> open_memstream.  The patch is attached below.  Is the implementation
> correct?  IIUC, the size parameter gets the size in wchars in case of
> having opened the memstream with open_wmemstream.  I hope I got that
> right.

Yes, that is how I read the spec.

> -  char saved; /* saved character that lived at *psize before NUL */
> +  union {
> +    char c;
> +    wchar_t w;
> +  } saved; /* saved character that lived at *psize before NUL */
> +  int wide;   /* wide-oriented (>0) or byte-oriented (<0) */

If wchar_t is 16 bits (as on cygwin), these last two fields occupy 64
bits.  I suggest using 'char wide' instead, since it reduces the size
requirement to 32 bits.

Beyond that, the patch looked fine to me.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Newlib mailing list