From 6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Sep 2008 12:27:29 +0200 Subject: fixed mixed declaration + code Although they are allowedd in C99, try to avoid them. Move variable declarations to the top of the current scope. --- src/src_lyrics.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/src_lyrics.c') diff --git a/src/src_lyrics.c b/src/src_lyrics.c index 4d41aea37..448c301ad 100644 --- a/src/src_lyrics.c +++ b/src/src_lyrics.c @@ -28,10 +28,12 @@ int get_text_line(formed_text *text, int num, char *dest, int len) { + int linelen; + memset(dest, '\0', len*sizeof(char)); if (num >= text->lines->len - 1) return -1; - int linelen; + if (num == 0) { linelen = g_array_index(text->lines, int, num); memcpy(dest, text->text->str, linelen*sizeof(char)); @@ -128,9 +130,10 @@ void src_lyr_stack_init(void) int src_lyr_init(void) { + int i = 0; + src_lyr_stack_init (); - int i = 0; while (g_array_index (src_lyr_stack, src_lyr*, i) != NULL) { src_lyr *i_stack; i_stack = g_array_index (src_lyr_stack, src_lyr*, i); @@ -150,12 +153,14 @@ int get_lyr_by_src (int priority, char *artist, char *title) static int src_lyr_load_plugin_file(const char *file) { GString *path; + src_lyr *new_src; + src_lyr_plugin_register register_func; + path = g_string_new (PLUGIN_DIR_SYSTEM); g_string_append (path, "/"); g_string_append (path, file); - src_lyr_plugin_register register_func; - src_lyr *new_src = malloc (sizeof (src_lyr)); + new_src = malloc(sizeof(src_lyr)); new_src->module = g_module_open (path->str, G_MODULE_BIND_LAZY); if (!g_module_symbol (new_src->module, "register_me", (gpointer*) ®ister_func)) return -1; @@ -178,13 +183,13 @@ static void src_lyr_plugins_load_from_dir(GDir *plugin_dir) static int src_lyr_plugins_load(void) { GDir *plugin_dir; + GString *user_dir_path; plugin_dir = g_dir_open (PLUGIN_DIR_SYSTEM, 0, NULL); if (plugin_dir == NULL) return -1; src_lyr_plugins_load_from_dir (plugin_dir); - GString *user_dir_path; user_dir_path = g_string_new (g_get_home_dir()); g_string_append (user_dir_path, PLUGIN_DIR_USER); -- cgit v1.2.3