diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-03 01:19:25 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-03 01:19:25 +0000 |
commit | 5adc8bdbb1471821f912becbba86e4631a4a001a (patch) | |
tree | fb0dabc347ab5050c13a9da4a1519eef752110ad | |
parent | be4b5ba0d143edd1001f33d226e10ef2c58f42ff (diff) |
Cleanups. Implement DEBUG() macro.
-rw-r--r-- | hardinfo2/benchmark.c | 9 | ||||
-rw-r--r-- | hardinfo2/computer.c | 12 | ||||
-rwxr-xr-x | hardinfo2/configure | 9 | ||||
-rw-r--r-- | hardinfo2/hardinfo.c | 8 | ||||
-rw-r--r-- | hardinfo2/iconcache.c | 58 | ||||
-rw-r--r-- | hardinfo2/menu.c | 5 | ||||
-rw-r--r-- | hardinfo2/shell.c | 6 | ||||
-rw-r--r-- | hardinfo2/util.c | 11 |
8 files changed, 65 insertions, 53 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index c6b1be62..49a5221a 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -60,13 +60,13 @@ static gchar *__benchmark_include_results(gchar * results, ShellOrderType order_type) { GKeyFile *conf; - gchar **machines, *bconf_path; + gchar **machines; int i; conf = g_key_file_new(); - bconf_path = - g_build_filename(params.path_data, "benchmark.conf", NULL); - g_key_file_load_from_file(conf, bconf_path, 0, NULL); + g_key_file_load_from_file(conf, + idle_free(g_build_filename(params.path_data, "benchmark.conf", NULL)), + 0, NULL); machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); for (i = 0; machines && machines[i]; i++) { @@ -79,7 +79,6 @@ static gchar *__benchmark_include_results(gchar * results, g_strfreev(machines); g_key_file_free(conf); - g_free(bconf_path); return g_strdup_printf("[$ShellParam$]\n" "Zebra=1\n" diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index 6f98aa09..7a50f8cc 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -115,12 +115,8 @@ hi_get_field(gchar * field) gchar *tmp; if (g_str_equal(field, "Memory")) { - MemoryInfo *mi; - - mi = computer_get_memory(); + MemoryInfo *mi = idle_free(computer_get_memory()); tmp = g_strdup_printf("%dMB (%dMB used)", mi->total, mi->used); - - g_free(mi); } else if (g_str_equal(field, "Uptime")) { tmp = computer_get_formatted_uptime(); } else if (g_str_equal(field, "Date/Time")) { @@ -219,10 +215,10 @@ gchar *callback_summary() "OpenGL Renderer=%s\n" "X11 Vendor=%s\n" "[Multimedia]\n" - "%s\n" + "\n%s\n" "[Input Devices]\n%s\n" - "%s\n" - "%s\n", + "\n%s\n" + "\n%s\n", (gchar*)idle_free(module_call_method("devices::getProcessorName")), computer->os->distro, computer->os->username, diff --git a/hardinfo2/configure b/hardinfo2/configure index 05e92c0e..068d99cc 100755 --- a/hardinfo2/configure +++ b/hardinfo2/configure @@ -162,7 +162,14 @@ echo "#define HOSTNAME \"`hostname`\"" >> config.h echo "#define PREFIX \"/usr/share/hardinfo/\"" >> config.h echo "#define LIBPREFIX \"/usr/lib/hardinfo/\"" >> config.h -echo "#define DEBUG 1" >> config.h + +if [ "$RELEASE" == "1" ]; then + echo "#define DEBUG(...)" >> config.h +else + echo '#define DEBUG(msg,...) g_print("*** %s:%d (%s) *** " msg "\n", \' >> config.h + echo ' __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)' >> config.h +fi + echo "#define ENABLE_BINRELOC 1" >> config.h echo "#define RELEASE $RELEASE" >> config.h diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 82f53f79..63257818 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -46,20 +46,19 @@ main(int argc, char **argv) " BinReloc enabled: %s\n" " Data prefix: %s\n" " Library prefix: %s\n" - " Compiled on: %s %s (%s)\n" - " Debugging enabled: %s\n\n", + " Compiled on: %s %s (%s)\n", RELEASE ? "Yes" : "No (" VERSION ")", ARCH, ENABLE_BINRELOC ? "Yes" : "No", PREFIX, LIBPREFIX, - PLATFORM, KERNEL, HOSTNAME, - DEBUG ? "Yes" : "No"); + PLATFORM, KERNEL, HOSTNAME); /* show also available modules */ params.list_modules = TRUE; } /* initialize the binreloc library, so we can load program data */ + DEBUG("initializing binreloc"); if (!binreloc_init(FALSE)) g_error("Failed to find runtime data.\n\n" "\342\200\242 Is HardInfo correctly installed?\n" @@ -86,6 +85,7 @@ main(int argc, char **argv) if (!params.create_report) { /* we only try to open the UI if the user didn't asked for a report. */ + DEBUG("initializing gtk+"); params.gui_running = ui_init(&argc, &argv); /* as a fallback, if GTK+ initialization failed, run in report diff --git a/hardinfo2/iconcache.c b/hardinfo2/iconcache.c index 868185e5..8b2e55e8 100644 --- a/hardinfo2/iconcache.c +++ b/hardinfo2/iconcache.c @@ -24,32 +24,34 @@ static GHashTable *cache = NULL; void icon_cache_init(void) { if (!cache) { - cache = g_hash_table_new(g_str_hash, g_str_equal); + cache = g_hash_table_new(g_str_hash, g_str_equal); } } -GdkPixbuf *icon_cache_get_pixbuf(const gchar *file) +GdkPixbuf *icon_cache_get_pixbuf(const gchar * file) { GdkPixbuf *icon; - - if (!cache) icon_cache_init(); - + + if (!cache) + icon_cache_init(); + icon = g_hash_table_lookup(cache, file); if (!icon) { - gchar *tmp = g_build_filename(params.path_data, "pixmaps", file, NULL); - icon = gdk_pixbuf_new_from_file(tmp, NULL); - g_hash_table_insert(cache, g_strdup(file), icon); - - g_free(tmp); + icon = + gdk_pixbuf_new_from_file(idle_free + (g_build_filename + (params.path_data, "pixmaps", file, + NULL)), NULL); + g_hash_table_insert(cache, g_strdup(file), icon); } - + g_object_ref(icon); - + return icon; } -GtkWidget *icon_cache_get_image(const gchar *file) +GtkWidget *icon_cache_get_image(const gchar * file) { GdkPixbuf *icon; @@ -57,32 +59,36 @@ GtkWidget *icon_cache_get_image(const gchar *file) return gtk_image_new_from_pixbuf(icon); } -GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei) +GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar * file, gint wid, + gint hei) { GdkPixbuf *icon; - - if (!cache) icon_cache_init(); + + if (!cache) + icon_cache_init(); icon = g_hash_table_lookup(cache, file); if (!icon) { - gchar *tmp = g_build_filename(params.path_data, "pixmaps", file, NULL); - - icon = gdk_pixbuf_new_from_file_at_size(tmp, wid, hei, NULL); - g_hash_table_insert(cache, g_strdup(file), icon); - - g_free(tmp); + icon = + gdk_pixbuf_new_from_file_at_size(idle_free + (g_build_filename + (params.path_data, "pixmaps", + file, NULL)), wid, hei, + NULL); + g_hash_table_insert(cache, g_strdup(file), icon); } - + g_object_ref(icon); - + return icon; } -GtkWidget *icon_cache_get_image_at_size(const gchar *file, gint wid, gint hei) +GtkWidget *icon_cache_get_image_at_size(const gchar * file, gint wid, + gint hei) { GdkPixbuf *icon; - + icon = icon_cache_get_pixbuf_at_size(file, wid, hei); return gtk_image_new_from_pixbuf(icon); } diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c index 250cfa10..cbd59431 100644 --- a/hardinfo2/menu.c +++ b/hardinfo2/menu.c @@ -103,7 +103,6 @@ void menu_init(Shell *shell) GtkActionGroup *action_group; /* Packing group for our Actions */ GtkUIManager *menu_manager; /* The magic widget! */ GError *error; /* For reporting exceptions or errors */ - gchar *uidefs_path; GtkAccelGroup *accel_group; /* Create our objects */ @@ -126,9 +125,7 @@ void menu_init(Shell *shell) /* Read in the UI from our XML file */ error = NULL; - uidefs_path = g_build_filename(params.path_data, "uidefs.xml", NULL); - gtk_ui_manager_add_ui_from_file(menu_manager, uidefs_path, &error); - g_free(uidefs_path); + gtk_ui_manager_add_ui_from_file(menu_manager, idle_free(g_build_filename(params.path_data, "uidefs.xml", NULL)), &error); if (error) { g_error("Building menus failed: %s", error->message); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index b05366be..d1faf8f5 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1058,10 +1058,8 @@ static void module_selected(GtkTreeSelection * ts, gpointer data) shell_status_update("Done."); shell_status_set_enabled(FALSE); - gchar *tmp = - g_strdup_printf("%s - System Information", entry->name); - gtk_window_set_title(GTK_WINDOW(shell->window), tmp); - g_free(tmp); + gtk_window_set_title(GTK_WINDOW(shell->window), + idle_free(g_strdup_printf("%s - System Information", entry->name))); shell_action_set_enabled("RefreshAction", TRUE); shell_action_set_enabled("CopyAction", TRUE); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 13194df3..fe8c1678 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -401,6 +401,8 @@ static void module_register_methods(ShellModule *module) g_hash_table_insert(__module_methods, method_name, method.function); g_free(name); + DEBUG("registering method %s", method_name); + if (!(*(++methods)).name) break; } @@ -544,6 +546,7 @@ static void module_free(ShellModule *module) g_object_unref(module->icon); /*g_module_close(module->dll);*/ + DEBUG("module_free: module->entries, %p\n", module->entries); g_slist_foreach(module->entries, (GFunc)module_entry_free, NULL); g_slist_free(module->entries); @@ -562,6 +565,8 @@ static GSList *modules_check_deps(GSList *modules) module = (ShellModule *) mm->data; + DEBUG("check deps: %s", module->name); + if (g_module_symbol(module->dll, "hi_module_get_dependencies", (gpointer) & get_deps)) { for (i = 0, deps = get_deps(); deps[i]; i++) { @@ -569,6 +574,8 @@ static GSList *modules_check_deps(GSList *modules) ShellModule *m; gboolean found = FALSE; + DEBUG(" depends on: %s", deps[i]); + for (l = modules; l; l = l->next) { m = (ShellModule *)l->data; gchar *name = g_path_get_basename(g_module_name(m->dll)); @@ -796,6 +803,8 @@ void tree_view_save_image(gchar *filename) static gboolean __idle_free_do(gpointer ptr) { + DEBUG("collecting garbage: %p", ptr); + g_free(ptr); return FALSE; @@ -803,7 +812,7 @@ static gboolean __idle_free_do(gpointer ptr) gpointer idle_free(gpointer ptr) { - g_timeout_add(2000, __idle_free_do, ptr); + g_timeout_add(5000, __idle_free_do, ptr); return ptr; } |