This is the mail archive of the libc-alpha@sourceware.cygnus.com 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]

iconv calling convention



If one wants to reset an iconv_t conversion descriptor to the initial state,
one needs to call iconv with two NULL pointers instead of char** pointers.
I expected that

          iconv(cd,NULL,NULL,NULL,NULL);

would do it, because if there is no input and output buffer, no "inbytesleft"
and "outbytesleft" counts need to be updated. But glibc-2.1.1 crashes on this.
It requires that I write

          size_t dummy;
          iconv(cd,NULL,NULL,NULL,&dummy);

Here is a patch which presumably fixes this.

             Bruno

*** iconv.c.bak	Wed Mar 17 22:03:42 1999
--- iconv.c	Mon Dec 20 00:04:13 1999
***************
*** 38,46 ****
  
    if (inbuf == NULL || *inbuf == NULL)
      {
!       result = __gconv (gcd, NULL, NULL, (unsigned char **) outbuf,
! 			(unsigned char *) (outstart + *outbytesleft),
! 			&converted);
      }
    else
      {
--- 38,49 ----
  
    if (inbuf == NULL || *inbuf == NULL)
      {
!       if (outbuf == NULL || *outbuf == NULL)
! 	result = __gconv (gcd, NULL, NULL, NULL, NULL, &converted);
!       else
! 	result = __gconv (gcd, NULL, NULL, (unsigned char **) outbuf,
! 			  (unsigned char *) (outstart + *outbytesleft),
! 			  &converted);
      }
    else
      {

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