From a4f0c8ef9a36cd9fb30dc6d9ec8cb0246ab1f918 Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Mon, 16 Sep 2013 09:17:11 +0200 Subject: [PATCH] Defined GswePlanetInfo as a boxed type --- src/swe-glib.c | 29 +++++++++++++++++++++++++++++ src/swe-glib.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/src/swe-glib.c b/src/swe-glib.c index 7731a3b..b87b03d 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -206,3 +206,32 @@ gswe_init(void) gswe_initialized = TRUE; } +static GswePlanetInfo * +gswe_planet_info_copy(GswePlanetInfo *planet_info) +{ + GswePlanetInfo *ret = g_new0(GswePlanetInfo, 1); + + ret->planet = planet_info->planet; + ret->sweph_id = planet_info->sweph_id; + ret->real_body = planet_info->real_body; + ret->orb = planet_info->orb; + ret->name = g_strdup(planet_info->name); + ret->points = planet_info->points; + ret->domicile_sign_1 = planet_info->domicile_sign_1; + ret->domicile_sign_2 = planet_info->domicile_sign_2; + ret->exile_sign_1 = planet_info->exile_sign_1; + ret->exile_sign_2 = planet_info->exile_sign_2; + ret->exalted_sign = planet_info->exalted_sign; + ret->fall_sign = planet_info->fall_sign; + + return ret; +} + +static void +gswe_planet_info_free(GswePlanetInfo *planet_info) +{ + g_free(planet_info->name); + g_free(planet_info); +} + +G_DEFINE_BOXED_TYPE(GswePlanetInfo, gswe_planet_info, (GBoxedCopyFunc)gswe_planet_info_copy, (GBoxedFreeFunc)gswe_planet_info_free); diff --git a/src/swe-glib.h b/src/swe-glib.h index 5aaf373..872c6be 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -33,5 +33,8 @@ extern GHashTable *gswe_mirror_info_table; void gswe_init(); +GType gswe_planet_info_get_type(void); +#define GSWE_TYPE_PLANET_INFO (gswe_planet_info_get_type()) + #endif /* __SWE_GLIB_H__ */