[MPlayer-dev-eng] [PATCH] gmplayer fsFileSelect related fixes

Sergey Pinaev dfo at antex.ru
Mon Apr 9 09:11:26 CEST 2007


On Mon, 9 Apr 2007 02:30:25 -0400
Rich Felker <dalias at aerifal.cx> wrote:

> On Mon, Apr 09, 2007 at 10:11:21AM +0400, Sergey Pinaev wrote:
> > On Sun, 08 Apr 2007 22:52:05 +1100
> > Vadim Pisarev <plv at farpost.com> wrote:
> > 
> > > -   gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
> > > +   gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)g_filename_to_utf8(get_current_dir_name(), -1, NULL, NULL, NULL) );
> > 
> > and who will free memory allocated by g_filename_to_utf8() ? Pushkin? =)
> 
> It uses a static buffer. It's intended only for immediate printing
> like here, nothing else.

gchar *
g_locale_to_utf8 (const gchar  *opsysstring,
                  gssize        len,
                  gsize        *bytes_read,
                  gsize        *bytes_written,
                  GError      **error)
{
  const char *charset;

  if (g_get_charset (&charset))
    return strdup_len (opsysstring, len, bytes_read, bytes_written, error);
  else
    return g_convert (opsysstring, len,
                      "UTF-8", charset, bytes_read, bytes_written, error);
}

g_convert ()
...
Returns : 	 If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise NULL and error will be set.

> > (btw, afaiu get_current_dir_name() returns malloc()ed string, that should
> > be free()d too)
> 
> If so then that should be fixed..

       get_current_dir_name,  which  is  only  prototyped  if  _GNU_SOURCE  is
       defined, will malloc(3) an array big enough to hold the current  direc-
       tory  name.

-- 
mail="Sergey Pinaev <dfo at antex.ru>"
url="http://`echo $mail | sed 's/.* <\(.*\)@\(.*\)>/\1.\2/'`"



More information about the MPlayer-dev-eng mailing list