This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/2962] const in iconv arg 2


------- Additional Comments From drahflow at gmx dot de  2007-05-10 16:17 -------
Ok, I read different opengroup standards, some stating the second parameter
should be const char **, others telling it should be char **.

The current libiconv documentation
(http://www.gnu.org/software/libiconv/documentation/libiconv/iconv.3.html)
says, it is const char **.

The _code_ uses it in the following fashion (only basically):

      result = __gconv (gcd, (const unsigned char **) inbuf,
                        (const unsigned char *)  (*inbuf + *inbytesleft),
                        (unsigned char **) outbuf,
                        (unsigned char *) (*outbuf + *outbytesleft),
                        &irreversible);

All other uses, are for checking == NULL...
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/iconv/iconv.c?rev=1.15&content-type=text/x-cvsweb-markup&cvsroot=glibc

After all a type is not just some fancy word, it is a contract between the iconv
function and it's user. And the contract includes (I assume this only, but every
documentation I read so far implies it) that iconv will _not_ change the inbuf
contents. So it should be const (once more).

I mean, just because some standard says it's char **, it is not any more right.
Either the function changes the values, then it's char **, or it does not then
it's const char **.

To users of the function this is especially unfriendly, because they either need
to cast their constant data (which is not guaranteed to work out well), or need
to copy it first (which is slow).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drahflow at gmx dot de
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


http://sourceware.org/bugzilla/show_bug.cgi?id=2962

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]