Mercurial > gftp.yaz
diff lib/config_file.c @ 207:cf4098008615
2003-7-1 Brian Masney <masneyb@gftp.org>
* lib/httpcommon.h lib/rfc2068.c - more HTTP improvements. Mostly with
chunked file transfers. Also fixed several memory leaks. Added more
informative error messages to aid in debugging. Size parsing fixes
* lib/misc.c (base64_encode) - alphabet fix (+ wasn't a valid
character, it should have been /) (thanks to Holger Kiehl
<Holger.Kiehl@dwd.de> for pointing this out)
* lib/config_file.c lib/gftp.h - added copy function for options
variables. The functions gftp_config_file_copy_text(),
gftp_config_file_copy_ptr_contents() and gftp_config_file_copy_color()
were added
* lib/protocols.c - make sure the remote_charsets string is restored
properly after it is used
* src/gtk/bookmarks.c - remove memory leak comments, these are fixed
now
* src/gtk/transfer.c - removed start_file_transfers variable
* src/gtk/misc-gtk.c src/gtk/gftp-gtk.h lib/misc.c lib/gftp.h - moved
get_next_selection() to lib
* acinclude.h (AC_TYPE_SOCKLEN_T) - AC_DEFINE fix (from
Nathan Robertson <nathanr@nathanr.net>)
author | masneyb |
---|---|
date | Wed, 02 Jul 2003 01:44:57 +0000 |
parents | 0098dae654a5 |
children | de6a2e8e51cb |
line wrap: on
line diff
--- a/lib/config_file.c Sat Jun 28 13:52:44 2003 +0000 +++ b/lib/config_file.c Wed Jul 02 01:44:57 2003 +0000 @@ -915,6 +915,28 @@ } +static void +gftp_config_file_copy_text (gftp_config_vars * cv, gftp_config_vars * dest_cv) +{ + if (dest_cv->flags & GFTP_CVARS_FLAGS_DYNMEM && dest_cv->value != NULL) + g_free (dest_cv->value); + + if (cv->value != NULL) + { + dest_cv->value = g_strdup ((char *) cv->value); + dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM; + } + else + dest_cv->value = NULL; +} + + +static void +gftp_config_file_copy_ptr_contents (gftp_config_vars * cv, gftp_config_vars * dest_cv) +{ + memcpy (&dest_cv->value, &cv->value, sizeof (dest_cv->value)); +} + static int gftp_config_file_read_int (char *str, gftp_config_vars * cv, int line) { @@ -998,6 +1020,18 @@ } +static void +gftp_config_file_copy_color (gftp_config_vars * cv, gftp_config_vars * dest_cv) +{ + if (dest_cv->flags & GFTP_CVARS_FLAGS_DYNMEM && dest_cv->value != NULL) + g_free (dest_cv->value); + + dest_cv->value = g_malloc (sizeof (gftp_color)); + memcpy (dest_cv->value, cv->value, sizeof (gftp_color)); + dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM; +} + + static int gftp_config_file_read_intcombo (char *str, gftp_config_vars * cv, int line) { @@ -1064,15 +1098,15 @@ /* Note, the index numbers of this array must match up to the numbers in gftp_option_type_enum in gftp.h */ gftp_option_type_var gftp_option_types[] = { - {gftp_config_file_read_text, gftp_config_file_write_text, NULL, NULL, NULL}, - {gftp_config_file_read_textcombo, gftp_config_file_write_text, NULL, NULL, NULL}, - {gftp_config_file_read_text, gftp_config_file_write_text, NULL, NULL, NULL}, - {gftp_config_file_read_text, gftp_config_file_write_hidetext, NULL, NULL, NULL}, - {gftp_config_file_read_int, gftp_config_file_write_int, NULL, NULL, NULL}, - {gftp_config_file_read_checkbox, gftp_config_file_write_int, NULL, NULL, NULL}, - {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo, NULL, NULL, NULL}, - {gftp_config_file_read_float, gftp_config_file_write_float, NULL, NULL, NULL}, - {gftp_config_file_read_color, gftp_config_file_write_color, NULL, NULL, NULL}, + {gftp_config_file_read_text, gftp_config_file_write_text, gftp_config_file_copy_text, NULL, NULL, NULL}, + {gftp_config_file_read_textcombo, gftp_config_file_write_text, gftp_config_file_copy_text, NULL, NULL, NULL}, + {gftp_config_file_read_text, gftp_config_file_write_text, gftp_config_file_copy_text, NULL, NULL, NULL}, + {gftp_config_file_read_text, gftp_config_file_write_hidetext, gftp_config_file_copy_text, NULL, NULL, NULL}, + {gftp_config_file_read_int, gftp_config_file_write_int, gftp_config_file_copy_ptr_contents, NULL, NULL, NULL}, + {gftp_config_file_read_checkbox, gftp_config_file_write_int, gftp_config_file_copy_ptr_contents, NULL, NULL, NULL}, + {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo, gftp_config_file_copy_ptr_contents, NULL, NULL, NULL}, + {gftp_config_file_read_float, gftp_config_file_write_float, gftp_config_file_copy_ptr_contents, NULL, NULL, NULL}, + {gftp_config_file_read_color, gftp_config_file_write_color, gftp_config_file_copy_color, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL} }; @@ -1204,8 +1238,11 @@ { g_hash_table_insert (*new_options_hash, (*new_options_vars)[i].key, &(*new_options_vars)[i]); + + (*new_options_vars)[i].value = NULL; + (*new_options_vars)[i].flags &= ~GFTP_CVARS_FLAGS_DYNMEM; - /* FIXME 2.0.15 - copy option values */ + gftp_option_types[(*new_options_vars)[i].otype].copy_function (&(orig_options)[i], &(*new_options_vars)[i]); } } @@ -1285,5 +1322,7 @@ tempentry = tempentry->next; g_free (delentry); } + + g_free (bookmarks); }