1
1

* charsets.c (load_codepages_list): Use glib memory allocation

functions.
(free_codepages_list) [HAVE_MAD]: New function to release
memory allocated in load_codepages_list.
* charsets.h: Declare free_codepages_list.

* main.c [HAVE_CHARSET]: Include charsets.h.
(main) [HAVE_MAD && HAVE_CHARSET]: Call free_codepages_list.
(program_name): Commented out.
Этот коммит содержится в:
Andrew V. Samoilov 2001-10-29 13:40:00 +00:00
родитель 3b32c84134
Коммит 1cd0a043a7
4 изменённых файлов: 43 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,15 @@
2001-10-29 Andrew V. Samoilov <kai@cmail.ru>
* charsets.c (load_codepages_list): Use glib memory allocation
functions.
(free_codepages_list) [HAVE_MAD]: New function to release
memory allocated in load_codepages_list.
* charsets.h: Declare free_codepages_list.
* main.c [HAVE_CHARSET]: Include charsets.h.
(main) [HAVE_MAD && HAVE_CHARSET]: Call free_codepages_list.
(program_name): Commented out.
2001-10-26 Andrew V. Samoilov <kai@cmail.ru>
* key.c (push_char): Fix buffer length calculation.

Просмотреть файл

@ -40,7 +40,7 @@ int load_codepages_list(void)
++n_codepages;
rewind( f );
codepages = calloc( n_codepages + 1, sizeof(struct codepage_desc) );
codepages = g_new0 ( struct codepage_desc, n_codepages + 1 );
for( n_codepages = 0; fgets( buf, sizeof buf, f ); ) {
/* split string into id and cpname */
@ -65,18 +65,18 @@ int load_codepages_list(void)
goto fail;
if (strcmp (buf, "default") == 0) {
default_codepage = strdup (p);
default_codepage = g_strdup (p);
continue;
}
codepages[n_codepages].id = strdup( buf );
codepages[n_codepages].name = strdup( p );
codepages[n_codepages].id = g_strdup( buf );
codepages[n_codepages].name = g_strdup( p );
++n_codepages;
}
if (default_codepage) {
display_codepage = get_codepage_index (default_codepage);
free (default_codepage);
g_free (default_codepage);
}
result = n_codepages;
@ -85,6 +85,22 @@ fail:
return result;
}
#ifdef HAVE_MAD
void free_codepages_list (void)
{
if (n_codepages > 0) {
int i;
for (i = 0; i < n_codepages; i++) {
g_free (codepages[i].id);
g_free (codepages[i].name);
}
n_codepages = 0;
g_free (codepages);
codepages = 0;
}
}
#endif /* HAVE_MAD */
#define OTHER_8BIT "Other_8_bit"
char *get_codepage_id( int n )

Просмотреть файл

@ -24,6 +24,7 @@ extern struct codepage_desc *codepages;
char *get_codepage_id( int n );
int get_codepage_index( const char *id );
int load_codepages_list(void);
void free_codepages_list(void);
char* init_printable_table( int cpdisplay );
char* init_translation_table( int cpsource, int cpdisplay );
void convert_to_display( char *str );

Просмотреть файл

@ -117,6 +117,10 @@
#include "../vfs/vfs.h"
#ifdef HAVE_CHARSET
#include "charsets.h"
#endif /* HAVE_CHARSET */
#include "popt.h"
/* "$Id$" */
@ -260,8 +264,10 @@ Dlg_head *midnight_dlg;
/* We need to paint it after CONSOLE_RESTORE, see: load_prompt */
int update_prompt = 0;
#if 0
/* The name which was used to invoke mc */
char *program_name;
#endif
/* The home directory */
char *home_dir;
@ -2854,6 +2860,9 @@ main (int argc, char *argv [])
#ifdef HAVE_MAD
done_key ();
#ifdef HAVE_CHARSET
free_codepages_list ();
#endif
#endif
mad_finalize (__FILE__, __LINE__);