Build fix
[babeltrace.git] / types / sequence.c
index 39a047022fc02b261e32109b2b9d8dabc193c114..f6025af61b3470fdda7c43ff2e8feefbdfa373e1 100644 (file)
@@ -1,25 +1,23 @@
 /*
- * BabelTrace - Sequence Type Converter
+ * sequence.c
  *
- * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * BabelTrace - Sequence Type Converter
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  */
 
 #include <babeltrace/compiler.h>
-#include <babeltrace/types.h>
+#include <babeltrace/format.h>
 
 void sequence_copy(struct stream_pos *dest, const struct format *fdest, 
                   struct stream_pos *src, const struct format *fsrc,
@@ -38,7 +36,7 @@ void sequence_copy(struct stream_pos *dest, const struct format *fdest,
 
        for (i = 0; i < len; i++) {
                struct type_class *elem_class = sequence_class->elem;
-               elem_class->copy(dest, fdest, src, fsrc, &elem_class->p);
+               elem_class->copy(dest, fdest, src, fsrc, elem_class);
        }
        fsrc->sequence_end(src, sequence_class);
        fdest->sequence_end(dest, sequence_class);
@@ -46,13 +44,15 @@ void sequence_copy(struct stream_pos *dest, const struct format *fdest,
 
 void sequence_type_free(struct type_class_sequence *sequence_class)
 {
-       sequence_class->elem->free(&sequence_class->elem->p);
+       sequence_class->elem->free(sequence_class->elem);
+       type_unref(&sequence_class->len_class->p);
+       type_unref(sequence_class->elem);
        g_free(sequence_class);
 }
 
 static void _sequence_type_free(struct type_class *type_class)
 {
-       struct type_class_struct *sequence_class =
+       struct type_class_sequence *sequence_class =
                container_of(type_class, struct type_class_sequence, p);
        sequence_type_free(sequence_class);
 }
@@ -62,19 +62,24 @@ sequence_type_new(const char *name, struct type_class_integer *len_class,
                  struct type_class *elem)
 {
        struct type_class_sequence *sequence_class;
+       struct type_class *type_class;
        int ret;
 
        sequence_class = g_new(struct type_class_sequence, 1);
-       type_class = &float_class->p;
+       type_class = &sequence_class->p;
 
        assert(!len_class->signedness);
 
-       sequence_class->len = len;
+       type_ref(&len_class->p);
+       sequence_class->len_class = len_class;
+       type_ref(elem);
+       sequence_class->elem = elem;
        type_class->name = g_quark_from_string(name);
        type_class->alignment = max(len_class->p.alignment,
-                                   elem->p.alignment);
+                                   elem->alignment);
        type_class->copy = sequence_copy;
        type_class->free = _sequence_type_free;
+       type_class->ref = 1;
 
        if (type_class->name) {
                ret = ctf_register_type(type_class);
@@ -84,8 +89,8 @@ sequence_type_new(const char *name, struct type_class_integer *len_class,
        return sequence_class;
 
 error_register:
-       len_class->p.free(&len_class->p);
-       sequence_class->elem->free(&sequence_class->elem->p);
+       type_unref(&len_class->p);
+       type_unref(elem);
        g_free(sequence_class);
        return NULL;
 }
This page took 0.024115 seconds and 4 git commands to generate.