[epiphany] smaps: Use G_DECLARE_FINAL_TYPE
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] smaps: Use G_DECLARE_FINAL_TYPE
- Date: Mon, 22 Feb 2016 05:05:12 +0000 (UTC)
commit ecf7e253a75b0c2e51ade8b590911a1435f72c7c
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Feb 21 22:59:56 2016 -0600
smaps: Use G_DECLARE_FINAL_TYPE
lib/ephy-smaps.c | 32 ++++++++++++++------------------
lib/ephy-smaps.h | 21 ++-------------------
2 files changed, 16 insertions(+), 37 deletions(-)
---
diff --git a/lib/ephy-smaps.c b/lib/ephy-smaps.c
index 7a5f378..9f15363 100644
--- a/lib/ephy-smaps.c
+++ b/lib/ephy-smaps.c
@@ -25,13 +25,14 @@
#include <stdio.h>
#include <string.h>
-G_DEFINE_TYPE (EphySMaps, ephy_smaps, G_TYPE_OBJECT)
-
-struct _EphySMapsPrivate {
+struct _EphySMaps {
+ GObject parent_instance;
GRegex *header;
GRegex *detail;
};
+G_DEFINE_TYPE (EphySMaps, ephy_smaps, G_TYPE_OBJECT)
+
typedef struct {
char *start;
char *end;
@@ -198,7 +199,6 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
VMA_t *vma = NULL;
GHashTable *anon_hash, *mapped_hash;
GSList *vma_entries = NULL, *p;
- EphySMapsPrivate *priv = smaps->priv;
path = g_strdup_printf ("/proc/%u/smaps", pid);
file = g_file_new_for_path (path);
@@ -220,7 +220,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
GMatchInfo *match_info = NULL;
gboolean matched = FALSE;
- g_regex_match (priv->header, line, 0, &match_info);
+ g_regex_match (smaps->header, line, 0, &match_info);
if (g_match_info_matches (match_info)) {
matched = TRUE;
@@ -244,7 +244,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
if (matched)
goto out;
- g_regex_match (priv->detail, line, 0, &match_info);
+ g_regex_match (smaps->detail, line, 0, &match_info);
if (g_match_info_matches (match_info)) {
char *name = g_match_info_fetch (match_info, 1);
char **size = NULL;
@@ -456,23 +456,21 @@ char* ephy_smaps_to_html (EphySMaps *smaps)
static void
ephy_smaps_init (EphySMaps *smaps)
{
- smaps->priv = G_TYPE_INSTANCE_GET_PRIVATE (smaps, EPHY_TYPE_SMAPS, EphySMapsPrivate);
-
/* Prepare the regexps for the smaps file. */
- smaps->priv->header = g_regex_new ("^([0-9a-f]+)-([0-9a-f]+) (....) ([0-9a-f]+) (..):(..) (\\d+) *(.*)$",
- G_REGEX_OPTIMIZE,
- 0,
- NULL);
- smaps->priv->detail = g_regex_new ("^(.*): +(\\d+) kB", G_REGEX_OPTIMIZE, 0, NULL);
+ smaps->header = g_regex_new ("^([0-9a-f]+)-([0-9a-f]+) (....) ([0-9a-f]+) (..):(..) (\\d+) *(.*)$",
+ G_REGEX_OPTIMIZE,
+ 0,
+ NULL);
+ smaps->detail = g_regex_new ("^(.*): +(\\d+) kB", G_REGEX_OPTIMIZE, 0, NULL);
}
static void
ephy_smaps_finalize (GObject *obj)
{
- EphySMapsPrivate *priv = EPHY_SMAPS (obj)->priv;
+ EphySMaps *smaps = EPHY_SMAPS (obj);
- g_regex_unref (priv->header);
- g_regex_unref (priv->detail);
+ g_regex_unref (smaps->header);
+ g_regex_unref (smaps->detail);
G_OBJECT_CLASS (ephy_smaps_parent_class)->finalize (obj);
}
@@ -483,8 +481,6 @@ ephy_smaps_class_init (EphySMapsClass *smaps_class)
GObjectClass *gobject_class = G_OBJECT_CLASS (smaps_class);
gobject_class->finalize = ephy_smaps_finalize;
-
- g_type_class_add_private (smaps_class, sizeof (EphySMapsPrivate));
}
EphySMaps *ephy_smaps_new (void)
diff --git a/lib/ephy-smaps.h b/lib/ephy-smaps.h
index dc55dd7..24768db 100644
--- a/lib/ephy-smaps.h
+++ b/lib/ephy-smaps.h
@@ -22,27 +22,10 @@
#include <glib-object.h>
-#define EPHY_TYPE_SMAPS (ephy_smaps_get_type ())
-#define EPHY_SMAPS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), EPHY_TYPE_SMAPS, EphySMaps))
-#define EPHY_SMAPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_SMAPS, EphySMapsClass))
-#define EPHY_IS_SMAPS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), EPHY_TYPE_SMAPS))
-#define EPHY_IS_SMAPS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TYPE_SMAPS))
-#define EPHY_SMAPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_SMAPS, EphySMapsClass))
+#define EPHY_TYPE_SMAPS (ephy_smaps_get_type ())
-typedef struct _EphySMapsPrivate EphySMapsPrivate;
+G_DECLARE_FINAL_TYPE (EphySMaps, ephy_smaps, EPHY, SMAPS, GObject)
-typedef struct {
- GObject parent;
-
- EphySMapsPrivate *priv;
-} EphySMaps;
-
-typedef struct {
- GObjectClass parent;
-
-} EphySMapsClass;
-
-GType ephy_smaps_get_type (void);
EphySMaps * ephy_smaps_new (void);
char * ephy_smaps_to_html (EphySMaps *smaps);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]