diff options
author | Thibaut Mattern <thibaut.mattern@gmail.com> | 2007-04-11 14:49:02 +0200 |
---|---|---|
committer | Thibaut Mattern <thibaut.mattern@gmail.com> | 2007-04-11 14:49:02 +0200 |
commit | 3dc931e217272f0781ef8f7d7ed228467fe5604c (patch) | |
tree | 0537b7c0d221db60f30121c4e4c64c8f84611419 /src | |
parent | 0ce330ec329e1d15a49ae5c5ea4741bcfbf924d3 (diff) | |
download | xine-lib-3dc931e217272f0781ef8f7d7ed228467fe5604c.tar.gz xine-lib-3dc931e217272f0781ef8f7d7ed228467fe5604c.tar.bz2 |
Released allocated strings.
Added some profiling (XINE_PROFILE).
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/configfile.c | 60 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 23 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 3 |
3 files changed, 52 insertions, 34 deletions
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 22d677e0b..294da5700 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -1371,7 +1371,6 @@ static int get_string(uint8_t *buffer, int buffer_size, int pos, char **value) { } static char* config_register_serialized_entry (config_values_t *this, const char *value) { - /* fields serialized : int type; @@ -1392,60 +1391,60 @@ static char* config_register_serialized_entry (config_values_t *this, const char int exp_level; int num_default; int num_value; - char *key; - char *str_default; - char *description; - char *help; - char **enum_values; + char *key = NULL; + char *str_default = NULL; + char *description = NULL; + char *help = NULL; + char **enum_values = NULL; int bytes; int pos; - void *output; + void *output = NULL; unsigned long output_len; - int value_count; + int value_count = 0; int i; output = base64_decode (value, strlen(value), &output_len); pos = 0; pos += bytes = get_int(output, output_len, pos, &type); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &range_min); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &range_max); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &exp_level); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &num_default); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &num_value); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &key); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &str_default); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &description); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_string(output, output_len, pos, &help); - if (!bytes) goto error; + if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &value_count); - if (!bytes) goto error; - if ((value_count < 0) || (value_count > 256)) goto error; + if (!bytes) goto exit; + if ((value_count < 0) || (value_count > 256)) goto exit; enum_values = malloc (sizeof(void*) * value_count + 1); for (i = 0; i < value_count; i++) { pos += bytes = get_string(output, output_len, pos, &enum_values[i]); - if (!bytes) goto error; + if (!bytes) goto exit; } enum_values[value_count] = NULL; @@ -1474,8 +1473,10 @@ static char* config_register_serialized_entry (config_values_t *this, const char switch (num_value) { case 0: this->register_string(this, key, str_default, description, help, exp_level, NULL, NULL); + break; default: this->register_filename(this, key, str_default, num_value, description, help, exp_level, NULL, NULL); + break; } break; case XINE_CONFIG_TYPE_RANGE: @@ -1494,12 +1495,21 @@ static char* config_register_serialized_entry (config_values_t *this, const char break; } +exit: + /* cleanup */ + free(str_default); + free(description); + free(help); + free(output); + + if (enum_values) { + for (i = 0; i < value_count; i++) { + free(enum_values[i]); + } + free(enum_values); + } return key; - -error: - /* serialization error */ - return NULL; } config_values_t *_x_config_init (void) { diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 2b7177511..fc708db13 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -48,6 +48,7 @@ /* #define LOG +#define DEBUG */ #define XINE_ENABLE_EXPERIMENTAL_FEATURES 1 @@ -697,7 +698,7 @@ static inline int _plugin_info_equal(const plugin_info_t *a, return 1; } -static void _attach_entry_to_node (plugin_node_t *node, void *key) { +static void _attach_entry_to_node (plugin_node_t *node, char *key) { if (!node->config_entry_list) { node->config_entry_list = xine_list_new(); @@ -713,7 +714,7 @@ static void _attach_entry_to_node (plugin_node_t *node, void *key) { static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { plugin_node_t *node = (plugin_node_t *)user_data; - _attach_entry_to_node(node, (void *)entry->key); + _attach_entry_to_node(node, strdup(entry->key)); } static int _load_plugin_class(xine_t *this, @@ -935,7 +936,7 @@ static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { while (ite) { char *key = xine_list_get_value(node->config_entry_list, ite); - /* now get the representation of the config key */ + /* now serialize the config key */ char *key_value = this->config->get_serialized_entry(this->config, key); lprintf(" config key: %s, serialization: %d bytes\n", key, strlen(key_value)); @@ -1205,7 +1206,7 @@ void _x_scan_plugins (xine_t *this) { homedir = strdup(xine_get_homedir()); this->plugin_catalog = _new_catalog(); - load_cached_catalog (this); + XINE_PROFILE(load_cached_catalog (this)); if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL) { pluginpath = strdup(pluginpath); @@ -1227,7 +1228,7 @@ void _x_scan_plugins (xine_t *this) { case XINE_PATH_SEPARATOR_CHAR: case '\0': plugindir[j] = '\0'; - collect_plugins(this, plugindir); + XINE_PROFILE(collect_plugins(this, plugindir)); j = 0; break; case '~': @@ -1244,9 +1245,9 @@ void _x_scan_plugins (xine_t *this) { free(pluginpath); free(homedir); - load_required_plugins (this); + /* load_required_plugins (this); */ - save_catalog (this); + XINE_PROFILE(save_catalog (this)); map_decoders (this); } @@ -2649,7 +2650,13 @@ static void dispose_plugin_list (xine_sarray_t *list) { free (node->info); if (node->config_entry_list) { - xine_list_delete(node->config_entry_list); + xine_list_iterator_t ite = xine_list_front (node->config_entry_list); + while (ite) { + char *key = xine_list_get_value (node->config_entry_list, ite); + free (key); + ite = xine_list_next (node->config_entry_list, ite); + } + xine_list_delete(node->config_entry_list); } free (node); } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index f49a988c9..32c2d7672 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -51,6 +51,7 @@ #define LOG_VERBOSE /* #define LOG +#define DEBUG */ #define XINE_ENABLE_EXPERIMENTAL_FEATURES @@ -1547,7 +1548,7 @@ void xine_init (xine_t *this) { /* * plugins */ - _x_scan_plugins(this); + XINE_PROFILE(_x_scan_plugins(this)); #ifdef HAVE_SETLOCALE if (!setlocale(LC_CTYPE, "")) |