[epiphany/gnome-keyring] Use g_slice_new0, remove rendundant checks and make _get_type()
- From: Priit Laes <plaes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-keyring] Use g_slice_new0, remove rendundant checks and make _get_type()
- Date: Wed, 29 Jul 2009 13:16:06 +0000 (UTC)
commit f8402de46e857993a0da4a578b1fdbea4ae75029
Author: Priit Laes <plaes plaes org>
Date: Wed Jul 29 16:11:21 2009 +0300
Use g_slice_new0, remove rendundant checks and make _get_type()
functionality threadsafe.
Signed-off-by: Priit Laes <plaes plaes org>
src/ephy-password-info.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/src/ephy-password-info.c b/src/ephy-password-info.c
index e923e57..4b5e87e 100644
--- a/src/ephy-password-info.c
+++ b/src/ephy-password-info.c
@@ -26,9 +26,7 @@
static EphyPasswordInfo*
password_info_copy (EphyPasswordInfo *info)
{
- EphyPasswordInfo *other = g_new (EphyPasswordInfo, 1);
- if (other == NULL)
- return NULL;
+ EphyPasswordInfo *other = g_slice_new0 (EphyPasswordInfo);
other->keyring_id = info->keyring_id;
other->secret = gnome_keyring_memory_strdup (info->secret);
@@ -45,22 +43,21 @@ password_info_free (EphyPasswordInfo *info)
GType
ephy_password_info_get_type (void)
{
- static GType type = 0;
- if (type == 0) {
- type = g_boxed_type_register_static("EphyTypePasswordInfo",
+ static volatile gsize type_volatile = 0;
+ if (g_once_init_enter (&type_volatile)) {
+ GType type = g_boxed_type_register_static(
+ g_intern_static_string ("EphyTypePasswordInfo"),
(GBoxedCopyFunc) password_info_copy,
(GBoxedFreeFunc) password_info_free);
+ g_once_init_leave (&type_volatile, type);
}
-
- return type;
+ return type_volatile;
}
EphyPasswordInfo
*ephy_password_info_new (guint32 key_id)
{
- EphyPasswordInfo *info = g_new0 (EphyPasswordInfo, 1);
- if (info == NULL)
- return NULL;
+ EphyPasswordInfo *info = g_slice_new0 (EphyPasswordInfo);
info->keyring_id = key_id;
return info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]