diff options
| -rw-r--r-- | hardinfo/hardinfo.c | 5 | ||||
| -rw-r--r-- | hardinfo/util.c | 98 | ||||
| -rw-r--r-- | includes/computer.h | 1 | ||||
| -rw-r--r-- | includes/devices.h | 1 | ||||
| -rw-r--r-- | includes/hardinfo.h | 9 | ||||
| -rw-r--r-- | includes/network.h | 1 | ||||
| -rw-r--r-- | modules/computer.c | 8 | ||||
| -rw-r--r-- | modules/computer/filesystem.c | 17 | ||||
| -rw-r--r-- | modules/computer/languages.c | 2 | ||||
| -rw-r--r-- | modules/computer/modules.c | 11 | ||||
| -rw-r--r-- | modules/computer/users.c | 11 | ||||
| -rw-r--r-- | modules/devices.c | 13 | ||||
| -rw-r--r-- | modules/devices/devmemory.c | 2 | ||||
| -rw-r--r-- | modules/devices/dmi.c | 2 | ||||
| -rw-r--r-- | modules/devices/inputdevices.c | 11 | ||||
| -rw-r--r-- | modules/devices/pci.c | 6 | ||||
| -rw-r--r-- | modules/devices/printers.c | 11 | ||||
| -rw-r--r-- | modules/devices/spd-decode.c | 4 | ||||
| -rw-r--r-- | modules/devices/storage.c | 22 | ||||
| -rw-r--r-- | modules/devices/usb.c | 22 | ||||
| -rw-r--r-- | modules/devices/x86/processor.c | 3 | ||||
| -rw-r--r-- | modules/network.c | 8 | ||||
| -rw-r--r-- | modules/network/net.c | 5 | 
23 files changed, 167 insertions, 106 deletions
| diff --git a/hardinfo/hardinfo.c b/hardinfo/hardinfo.c index 784a3c06..ffe35920 100644 --- a/hardinfo/hardinfo.c +++ b/hardinfo/hardinfo.c @@ -115,6 +115,9 @@ int main(int argc, char **argv)      /* initialize vendor database */      vendor_init(); +    /* initialize moreinfo */ +    moreinfo_init(); +      if (params.run_xmlrpc_server) {          g_type_init(); @@ -156,6 +159,8 @@ int main(int argc, char **argv)          g_error("Don't know what to do. Exiting.");      } +    moreinfo_shutdown(); +      DEBUG("finished");      return 0;  } diff --git a/hardinfo/util.c b/hardinfo/util.c index 0f88c388..1640be8b 100644 --- a/hardinfo/util.c +++ b/hardinfo/util.c @@ -1288,3 +1288,101 @@ h_sysfs_read_string(gchar *endpoint, gchar *entry)  	return return_value;  } +static GHashTable *_moreinfo = NULL; + +void +moreinfo_init(void) +{ +	if (G_UNLIKELY(_moreinfo)) { +		DEBUG("moreinfo already initialized"); +		return; +	} +	DEBUG("initializing moreinfo"); +	_moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); +} + +void +moreinfo_shutdown(void) +{ +	if (G_UNLIKELY(!_moreinfo)) { +		DEBUG("moreinfo not initialized"); +		return; +	} +	DEBUG("shutting down moreinfo"); +	g_hash_table_destroy(_moreinfo); +	_moreinfo = NULL; +} + +void +moreinfo_add_with_prefix(gchar *prefix, gchar *key, gchar *value) +{ +	if (G_UNLIKELY(!_moreinfo)) { +		DEBUG("moreinfo not initialized"); +		return; +	} +	 +	if (prefix) { +		gchar *hashkey = g_strconcat(prefix, ":", key, NULL); +		g_hash_table_insert(_moreinfo, hashkey, value); +		return; +	} + +	g_hash_table_insert(_moreinfo, g_strdup(key), value); +} + +void +moreinfo_add(gchar *key, gchar *value) +{ +	moreinfo_add_with_prefix(NULL, key, value); +} + +static gboolean +_moreinfo_del_cb(gpointer key, gpointer value, gpointer data) +{ +	return g_str_has_prefix(key, data); +} + +void +moreinfo_del_with_prefix(gchar *prefix) +{ +	if (G_UNLIKELY(!_moreinfo)) { +		DEBUG("moreinfo not initialized"); +		return; +	} +	 +	g_hash_table_foreach_remove(_moreinfo, _moreinfo_del_cb, prefix); +} + +void +moreinfo_clear(void) +{ +	if (G_UNLIKELY(!_moreinfo)) { +		DEBUG("moreinfo not initialized"); +		return; +	} +	h_hash_table_remove_all(_moreinfo); +} + +gchar * +moreinfo_lookup_with_prefix(gchar *prefix, gchar *key) +{ +	if (G_UNLIKELY(!_moreinfo)) { +		DEBUG("moreinfo not initialized"); +		return; +	} +	 +	if (prefix) { +		gchar *lookup_key = g_strconcat(prefix, ":", key, NULL); +		gchar *result = g_hash_table_lookup(_moreinfo, lookup_key); +		g_free(lookup_key); +		return result; +	} + +	return g_hash_table_lookup(_moreinfo, key); +} + +gchar * +moreinfo_lookup(gchar *key) +{ +	return moreinfo_lookup_with_prefix(NULL, key); +} diff --git a/includes/computer.h b/includes/computer.h index 361dc25d..fd2ebe60 100644 --- a/includes/computer.h +++ b/includes/computer.h @@ -166,7 +166,6 @@ extern gchar *groups;  extern gchar *fs_list;  extern GHashTable *_module_hash_table;  extern Computer *computer; -extern GHashTable *moreinfo;  extern gchar *module_list;  gchar *computer_get_formatted_loadavg(); diff --git a/includes/devices.h b/includes/devices.h index 2452d914..3af92f60 100644 --- a/includes/devices.h +++ b/includes/devices.h @@ -83,7 +83,6 @@ extern gchar *storage_icons;  extern gchar *storage_list;  extern gchar *usb_list;  extern GHashTable *memlabels; -extern GHashTable *moreinfo;  extern GHashTable *_pci_devices;  extern GHashTable *sensor_compute;  extern GHashTable *sensor_labels; diff --git a/includes/hardinfo.h b/includes/hardinfo.h index 42a92a30..23a9468a 100644 --- a/includes/hardinfo.h +++ b/includes/hardinfo.h @@ -148,4 +148,13 @@ gchar	       *h_sysfs_read_string(gchar *endpoint, gchar *entry);  #define _CONCAT(a,b) a ## b  #define CONCAT(a,b) _CONCAT(a,b) +void moreinfo_init(void); +void moreinfo_shutdown(void); +void moreinfo_add_with_prefix(gchar *prefix, gchar *key, gchar *value); +void moreinfo_add(gchar *key, gchar *value); +void moreinfo_del_with_prefix(gchar *prefix); +void moreinfo_clear(void); +gchar *moreinfo_lookup_with_prefix(gchar *prefix, gchar *key); +gchar *moreinfo_lookup(gchar *key); +  #endif				/* __HARDINFO_H__ */ diff --git a/includes/network.h b/includes/network.h index e8113089..1e71126e 100644 --- a/includes/network.h +++ b/includes/network.h @@ -7,7 +7,6 @@ extern gchar *smb_shares_list;  extern gchar *nfs_shares_list;  extern gchar *network_interfaces;  extern gchar *network_icons; -extern GHashTable *moreinfo;  void scan_net_interfaces(void); diff --git a/modules/computer.c b/modules/computer.c index 7d3c5d8d..8656b361 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -81,13 +81,12 @@ static ModuleEntry entries[] = {      {NULL},  }; -GHashTable *moreinfo = NULL;  gchar *module_list = NULL;  Computer *computer = NULL;  gchar *hi_more_info(gchar * entry)  { -    gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); +    gchar *info = moreinfo_lookup_with_prefix("COMP", entry);      if (info)  	return g_strdup(info); @@ -684,15 +683,12 @@ void hi_module_deinit(void)      g_free(computer->date_time);      g_free(computer); -    h_hash_table_remove_all(moreinfo); -    g_hash_table_destroy(moreinfo); +    moreinfo_del_with_prefix("COMP");  }  void hi_module_init(void)  {      computer = g_new0(Computer, 1); -    moreinfo = -	g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);  }  ModuleAbout *hi_module_get_about(void) diff --git a/modules/computer/filesystem.c b/modules/computer/filesystem.c index fcd8cf31..a7162777 100644 --- a/modules/computer/filesystem.c +++ b/modules/computer/filesystem.c @@ -27,12 +27,6 @@  gchar *fs_list = NULL; -static gboolean -remove_filesystem_entries(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "FS"); -} -  void  scan_filesystems(void)  { @@ -43,7 +37,7 @@ scan_filesystems(void)      g_free(fs_list);      fs_list = g_strdup(""); -    g_hash_table_foreach_remove(moreinfo, remove_filesystem_entries, NULL); +    moreinfo_del_with_prefix("COMP:FS");      mtab = fopen("/etc/mtab", "r");      if (!mtab) @@ -76,13 +70,8 @@ scan_filesystems(void)  	  	      *strused = size_human_readable(used);  		gchar *strhash; -		if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) { -		    g_hash_table_remove(moreinfo, tmp[0]); -		    g_free(strhash); -		}  		strreplacechr(tmp[0], "#", '_'); -		  		strhash = g_strdup_printf("[%s]\n"  					  "Filesystem=%s\n"  					  "Mounted As=%s\n" @@ -95,7 +84,9 @@ scan_filesystems(void)  					  strstr(tmp[3], "rw") ? "Read-Write" :  					  "Read-Only", tmp[1], strsize, strused,  					  stravail); -		g_hash_table_insert(moreinfo, g_strdup_printf("FS%d", ++count), strhash); +               gchar *key = g_strdup_printf("FS%d", ++count); +		moreinfo_add_with_prefix("COMP", key, strhash); +		g_free(key);  		fs_list = h_strdup_cprintf("$FS%d$%s=%.2f %% (%s of %s)|%s\n",  					  fs_list, diff --git a/modules/computer/languages.c b/modules/computer/languages.c index 2808da1b..5877c41c 100644 --- a/modules/computer/languages.c +++ b/modules/computer/languages.c @@ -89,7 +89,7 @@ scan_languages(OperatingSystem * os)  					 FIELD(date), FIELD(codeset));  #undef FIELD -	    g_hash_table_insert(moreinfo, g_strdup(name), currlocale); +           moreinfo_add_with_prefix("COMP", name, currlocale);  	    g_free(title);  	    g_free(source); diff --git a/modules/computer/modules.c b/modules/computer/modules.c index 743ba176..dc4c1815 100644 --- a/modules/computer/modules.c +++ b/modules/computer/modules.c @@ -28,12 +28,6 @@      continue;                        					\    } -static gboolean -remove_module_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "MOD"); -} -  GHashTable *_module_hash_table = NULL;  void @@ -50,7 +44,7 @@ scan_modules_do(void)      g_free(module_list);      module_list = NULL; -    g_hash_table_foreach_remove(moreinfo, remove_module_devices, NULL); +    moreinfo_del_with_prefix("COMP:MOD");      lsmod_path = find_program("lsmod");      lsmod = popen(lsmod_path, "r"); @@ -158,7 +152,8 @@ scan_modules_do(void)  	    g_free(deps);  	} -	g_hash_table_insert(moreinfo, hashkey, strmodule); +	moreinfo_add_with_prefix("COMP", hashkey, strmodule); +	g_free(hashkey);  	g_free(license);  	g_free(description); diff --git a/modules/computer/users.c b/modules/computer/users.c index e303ac6e..e8f891ac 100644 --- a/modules/computer/users.c +++ b/modules/computer/users.c @@ -22,12 +22,6 @@  gchar *users = NULL; -static gboolean -remove_users(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "USER"); -} -  void  scan_users_do(void)  { @@ -38,7 +32,7 @@ scan_users_do(void)      if (users) {          g_free(users); -        g_hash_table_foreach_remove(moreinfo, remove_users, NULL); +        moreinfo_del_with_prefix("COMP:USER");      }      users = g_strdup(""); @@ -54,11 +48,12 @@ scan_users_do(void)                  (gint) passwd_->pw_gid,                  passwd_->pw_dir,                  passwd_->pw_shell); -        g_hash_table_insert(moreinfo, key, val); +        moreinfo_add_with_prefix("COMP", key, val);          strend(passwd_->pw_gecos, ',');          users = h_strdup_cprintf("$%s$%s=%s\n", users, key, passwd_->pw_name, passwd_->pw_gecos);          passwd_ = getpwent(); +        g_free(key);      }      endpwent(); diff --git a/modules/devices.c b/modules/devices.c index a8f990ed..8e2daa27 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -98,8 +98,6 @@ gchar *battery_list = NULL;  gchar *meminfo = NULL;  gchar *lginterval = NULL; -GHashTable *moreinfo = NULL; -  #include <vendor.h>  gchar *get_processor_name(void) @@ -186,8 +184,8 @@ gchar *get_motherboard(void)      scan_dmi(FALSE); -    board_name = (gchar *)g_hash_table_lookup(moreinfo, "DMI:Board:Name"); -    board_vendor = (gchar *)g_hash_table_lookup(moreinfo, "DMI:Board:Vendor"); +    board_name = moreinfo_lookup("DEV:DMI:Board:Name"); +    board_vendor = moreinfo_lookup("DEV:DMI:Board:Vendor");      if (board_name && board_vendor && *board_name && *board_vendor)         return g_strconcat(board_vendor, " ", board_name, NULL); @@ -219,7 +217,7 @@ ShellModuleMethod *hi_exported_methods(void)  gchar *hi_more_info(gchar * entry)  { -    gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); +    gchar *info = moreinfo_lookup_with_prefix("DEV", entry);      if (info)  	return g_strdup(info); @@ -229,7 +227,7 @@ gchar *hi_more_info(gchar * entry)  gchar *hi_get_field(gchar * field)  { -    gchar *info = (gchar *) g_hash_table_lookup(moreinfo, field); +    gchar *info = moreinfo_lookup_with_prefix("DEV", field);      if (info)  	return g_strdup(info); @@ -445,7 +443,6 @@ void hi_module_init(void)      }  #endif	/* defined(ARCH_x86) */ -    moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);      init_memory_labels();      init_cups();      sensors_init(); @@ -453,8 +450,8 @@ void hi_module_init(void)  void hi_module_deinit(void)  { +    moreinfo_del_with_prefix("DEV");      sensors_shutdown(); -    g_hash_table_destroy(moreinfo);      g_hash_table_destroy(memlabels);      g_module_close(cups);  } diff --git a/modules/devices/devmemory.c b/modules/devices/devmemory.c index 8c89d567..31fd8915 100644 --- a/modules/devices/devmemory.c +++ b/modules/devices/devmemory.c @@ -64,7 +64,7 @@ void scan_memory_do(void)              newkeys[0] = g_strdup(tmp);          } -        g_hash_table_replace(moreinfo, g_strdup(newkeys[0]), g_strdup(newkeys[1])); +        moreinfo_add_with_prefix("DEV", newkeys[0], g_strdup(newkeys[1]));          tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL);          g_free(meminfo); diff --git a/modules/devices/dmi.c b/modules/devices/dmi.c index 9d54fa9c..9c6e3009 100644 --- a/modules/devices/dmi.c +++ b/modules/devices/dmi.c @@ -46,7 +46,7 @@ gchar *dmi_info = NULL;  static void add_to_moreinfo(const char *group, const char *key, char *value)  {    char *new_key = g_strconcat("DMI:", group, ":", key, NULL); -  g_hash_table_replace(moreinfo, new_key, g_strdup(g_strstrip(value))); +  moreinfo_add_with_prefix("DEV", new_key, g_strdup(g_strstrip(value)));  }  gboolean dmi_get_info_dmidecode() diff --git a/modules/devices/inputdevices.c b/modules/devices/inputdevices.c index 31f51fbb..5ff415cf 100644 --- a/modules/devices/inputdevices.c +++ b/modules/devices/inputdevices.c @@ -23,12 +23,6 @@  gchar *input_icons = NULL; -static gboolean -remove_input_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "INP"); -} -  static struct {      char *name;      char *icon; @@ -54,7 +48,7 @@ __scan_input_devices(void)  	return;      if (input_list) { -	g_hash_table_foreach_remove(moreinfo, remove_input_devices, NULL); +        moreinfo_del_with_prefix("DEV:INP");  	g_free(input_list);  	g_free(input_icons);      } @@ -133,7 +127,8 @@ __scan_input_devices(void)  				 	     strhash);  	    } -	    g_hash_table_insert(moreinfo, tmp, strhash); +	    moreinfo_add_with_prefix("DEV", tmp, strhash); +	    g_free(tmp);  	    g_free(phys);  	    g_free(name); diff --git a/modules/devices/pci.c b/modules/devices/pci.c index a8439019..91ff914d 100644 --- a/modules/devices/pci.c +++ b/modules/devices/pci.c @@ -166,7 +166,8 @@ scan_pci_do(void)  	    gpointer start, end;  	    if (strdevice != NULL && strhash != NULL) { -		g_hash_table_insert(moreinfo, strhash, strdevice); +                moreinfo_add_with_prefix("DEV", strhash, strdevice); +                g_free(strhash);                  g_free(category);                  g_free(name);  	    } @@ -235,7 +236,8 @@ pci_error:          pci_list = g_strconcat(pci_list, "No PCI devices found=\n", NULL);      } else if (strhash) {  	/* insert the last device */ -        g_hash_table_insert(moreinfo, strhash, strdevice); +        moreinfo_add_with_prefix("DEV", strhash, strdevice); +        g_free(strhash);          g_free(category);          g_free(name);      } diff --git a/modules/devices/printers.c b/modules/devices/printers.c index 80851a00..013291cf 100644 --- a/modules/devices/printers.c +++ b/modules/devices/printers.c @@ -42,12 +42,6 @@ static gboolean cups_init = FALSE;  GModule *cups; -static gboolean -remove_printer_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "PRN"); -} -  void  init_cups(void)  { @@ -199,7 +193,7 @@ scan_printers_do(void)      }      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(moreinfo, remove_printer_devices, NULL); +    moreinfo_del_with_prefix("DEV:PRN");      num_dests = cups_dests_get(&dests);      if (num_dests > 0) { @@ -259,7 +253,8 @@ scan_printers_do(void)                }              } -            g_hash_table_insert(moreinfo, prn_id, prn_moreinfo); +            moreinfo_add_with_prefix("DEV", prn_id, prn_moreinfo); +            g_free(prn_id);              g_hash_table_destroy(options);  	} diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c index bb22c1b7..d559555f 100644 --- a/modules/devices/spd-decode.c +++ b/modules/devices/spd-decode.c @@ -1295,7 +1295,9 @@ static gchar *decode_dimms(GSList *dimm_list, gboolean use_sysfs)          decode_module_manufacturer(bytes, &manufacturer);          decode_module_part_number(bytes, part_number); -        g_hash_table_insert(moreinfo, g_strdup_printf("MEM%d", count), g_strdup(detailed_info)); +        gchar *key = g_strdup_printf("MEM%d", count); +        moreinfo_add_with_prefix("DEV", key, g_strdup(detailed_info)); +        g_free(key);          g_string_append_printf(output,                                 "$MEM%d$%d=%s|%d MB|%s\n",                                 count, count, diff --git a/modules/devices/storage.c b/modules/devices/storage.c index a9dfd665..3df6c765 100644 --- a/modules/devices/storage.c +++ b/modules/devices/storage.c @@ -23,12 +23,6 @@  gchar *storage_icons = NULL; -static gboolean -remove_scsi_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "SCSI"); -} -  /* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */  void  __scan_scsi_devices(void) @@ -44,7 +38,7 @@ __scan_scsi_devices(void)      gchar *scsi_storage_list;      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(moreinfo, remove_scsi_devices, NULL); +    moreinfo_del_with_prefix("DEV:SCSI");      if (!g_file_test("/proc/scsi/scsi", G_FILE_TEST_EXISTS))  	return; @@ -141,7 +135,8 @@ __scan_scsi_devices(void)                                             scsi_channel,                                             scsi_id,                                             scsi_lun); -                g_hash_table_insert(moreinfo, devid, strhash); +                moreinfo_add_with_prefix("DEV", devid, strhash); +                g_free(devid);                  g_free(model);                  g_free(revision); @@ -159,12 +154,6 @@ __scan_scsi_devices(void)      }  } -static gboolean -remove_ide_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "IDE"); -} -  void  __scan_ide_devices(void)  { @@ -175,7 +164,7 @@ __scan_ide_devices(void)      gchar *capab = NULL, *speed = NULL, *driver = NULL, *ide_storage_list;      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(moreinfo, remove_ide_devices, NULL); +    moreinfo_del_with_prefix("DEV:IDE");      ide_storage_list = g_strdup("\n[IDE Disks]\n"); @@ -362,7 +351,8 @@ __scan_ide_devices(void)                  speed = NULL;              } -	    g_hash_table_insert(moreinfo, devid, strhash); +           moreinfo_add_with_prefix("DEV", devid, strhash); +           g_free(devid);  	    g_free(model);  	    model = g_strdup(""); diff --git a/modules/devices/usb.c b/modules/devices/usb.c index a8868b1e..62fe258c 100644 --- a/modules/devices/usb.c +++ b/modules/devices/usb.c @@ -27,12 +27,6 @@  gchar *usb_list = NULL; -static gboolean -remove_usb_devices(gpointer key, gpointer value, gpointer data) -{ -    return g_str_has_prefix(key, "USB"); -} -  void __scan_usb_sysfs_add_device(gchar * endpoint, int n)  {      gchar *manufacturer, *product, *mxpwr, *tmp, *strhash; @@ -90,8 +84,8 @@ void __scan_usb_sysfs_add_device(gchar * endpoint, int n)  			      mxpwr,  			      version, classid, vendor, prodid, bus); -    g_hash_table_insert(moreinfo, tmp, strhash); - +    moreinfo_add_with_prefix("DEV", tmp, strhash); +    g_free(tmp);      g_free(manufacturer);      g_free(product);      g_free(mxpwr); @@ -109,7 +103,7 @@ gboolean __scan_usb_sysfs(void)      }      if (usb_list) { -	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL); +       moreinfo_del_with_prefix("DEV:USB");  	g_free(usb_list);      }      usb_list = g_strdup("[USB Devices]\n"); @@ -148,7 +142,7 @@ gboolean __scan_usb_procfs(void)  	return 0;      if (usb_list) { -	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL); +       moreinfo_del_with_prefix("DEV:USB");  	g_free(usb_list);      }      usb_list = g_strdup("[USB Devices]\n"); @@ -233,7 +227,8 @@ gboolean __scan_usb_procfs(void)  					   ver, rev, classid,  					   vendor, prodid, bus, level); -		g_hash_table_insert(moreinfo, tmp, strhash); +               moreinfo_add_with_prefix("DEV", tmp, strhash); +               g_free(tmp);  	    }  	    g_free(manuf); @@ -317,13 +312,14 @@ void __scan_usb_lsusb_add_device(char *buffer, FILE *lsusb, int usb_device_numbe  			      dev_class ? g_strstrip(dev_class) : "Unknown",  			      vendor_id, product_id, bus); -    g_hash_table_insert(moreinfo, tmp, strhash); +    moreinfo_add_with_prefix("DEV", tmp, strhash);      g_free(vendor);      g_free(product);      g_free(max_power);      g_free(dev_class);      g_free(version); +    g_free(tmp);  }  gboolean __scan_usb_lsusb(void) @@ -352,7 +348,7 @@ gboolean __scan_usb_lsusb(void)      g_free(temp);      if (usb_list) { -	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL); +       moreinfo_del_with_prefix("DEV:USB");  	g_free(usb_list);      }      usb_list = g_strdup("[USB Devices]\n"); diff --git a/modules/devices/x86/processor.c b/modules/devices/x86/processor.c index e70d1374..2609720e 100644 --- a/modules/devices/x86/processor.c +++ b/modules/devices/x86/processor.c @@ -545,8 +545,9 @@ gchar *processor_get_info(GSList * processors)  				  processor->cpu_mhz);  	    hashkey = g_strdup_printf("CPU%d", processor->id); -	    g_hash_table_insert(moreinfo, hashkey, +	    moreinfo_add_with_prefix("DEV", hashkey,  				processor_get_detailed_info(processor)); +           g_free(hashkey);  	}  	ret = g_strdup_printf("[$ShellParam$]\n" diff --git a/modules/network.c b/modules/network.c index f3864498..95cec5ec 100644 --- a/modules/network.c +++ b/modules/network.c @@ -37,8 +37,6 @@  #include "network.h" -GHashTable *moreinfo = NULL; -  /* Callbacks */  gchar *callback_network();  gchar *callback_route(); @@ -383,7 +381,7 @@ gchar *callback_statistics()  gchar *hi_more_info(gchar * entry)  { -    gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); +    gchar *info = moreinfo_lookup_with_prefix("NET", entry);      if (info)  	return g_strdup(info); @@ -408,13 +406,11 @@ guchar hi_module_get_weight(void)  void hi_module_init(void)  { -    moreinfo = -	g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);  }  void hi_module_deinit(void)  { -    g_hash_table_destroy(moreinfo); +    moreinfo_del_with_prefix("NET");      g_free(smb_shares_list);      g_free(nfs_shares_list); diff --git a/modules/network/net.c b/modules/network/net.c index f8451239..5612204c 100644 --- a/modules/network/net.c +++ b/modules/network/net.c @@ -433,7 +433,8 @@ static void scan_net_interfaces_24(void)  				     broadcast : "Not set");  	    } -	    g_hash_table_insert(moreinfo, devid, detailed); +	    moreinfo_add_with_prefix("NET", devid, detailed); +	    g_free(devid);  	}      }      fclose(proc_net); @@ -445,7 +446,7 @@ void scan_net_interfaces(void)         that instead of /proc/net/dev */      /* remove old devices from global device table */ -    g_hash_table_foreach_remove(moreinfo, remove_net_devices, NULL); +    moreinfo_del_with_prefix("NET");      scan_net_interfaces_24();  } | 
