X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Ffloat.c;h=e42daa162170c39d388caba940178da3e4ea14db;hp=ac1525595bc99c82a95f9cd2bc62321c6480be54;hb=90b676d73fc6f817958083c0f159028a2f0b40ca;hpb=0a46062b3916eda6f871b5d80c4b97dcb3804d37 diff --git a/types/float.c b/types/float.c index ac152559..e42daa16 100644 --- a/types/float.c +++ b/types/float.c @@ -19,6 +19,7 @@ */ #include +#include size_t float_copy(unsigned char *dest, const struct format *fdest, const unsigned char *src, const struct format *fsrc, @@ -38,6 +39,18 @@ size_t float_copy(unsigned char *dest, const struct format *fdest, } } +void float_type_free(struct type_class_float *float_class) +{ + g_free(float_class); +} + +static void _float_type_free(struct type_class *type_class) +{ + struct type_class_float *float_class = + container_of(type_class, struct type_class_float, p); + float_type_free(float_class); +} + struct type_class_float *float_type_new(const char *name, size_t mantissa_len, size_t exp_len, int byte_order, @@ -46,12 +59,11 @@ struct type_class_float *float_type_new(const char *name, struct type_class_float *float_class; int ret; - /* - * Freed when type is unregistered. - */ float_class = g_new(struct type_class_float, 1); float_class->p.name = g_quark_from_string(name); float_class->p.alignment = alignment; + float_class->p.copy = float_copy; + float_class->p.free = _float_type_free; float_class->mantissa_len = mantissa_len; float_class->exp_len = exp_len; float_class->byte_order = byte_order; @@ -64,9 +76,3 @@ struct type_class_float *float_type_new(const char *name, } return float_class; } - -void float_type_free(struct type_class_float *float_class) -{ - if (!float_class->name) - g_free(float_class); -}