Defined GswePlanetInfo as a boxed type

This commit is contained in:
Gergely Polonkai 2013-09-16 09:17:11 +02:00
parent 5c3e05ce56
commit a4f0c8ef9a
2 changed files with 32 additions and 0 deletions

View File

@ -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);

View File

@ -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__ */