Fix: array and sequence field's 'elems' members can be left NULL
[babeltrace.git] / types / sequence.c
index 8792325e834427f5855c61651f9de0f33e73bf09..dcbcf19a76075ab815ad71160e6ae46288a7c3d0 100644 (file)
@@ -32,7 +32,7 @@
 #include <inttypes.h>
 
 static
-struct bt_definition *_sequence_definition_new(struct declaration *declaration,
+struct bt_definition *_sequence_definition_new(struct bt_declaration *declaration,
                                        struct definition_scope *parent_scope,
                                        GQuark field_name, int index,
                                        const char *root_name);
@@ -88,7 +88,7 @@ int bt_sequence_rw(struct bt_stream_pos *pos, struct bt_definition *definition)
 }
 
 static
-void _sequence_declaration_free(struct declaration *declaration)
+void _sequence_declaration_free(struct bt_declaration *declaration)
 {
        struct declaration_sequence *sequence_declaration =
                container_of(declaration, struct declaration_sequence, p);
@@ -101,11 +101,11 @@ void _sequence_declaration_free(struct declaration *declaration)
 
 struct declaration_sequence *
        bt_sequence_declaration_new(const char *length,
-                         struct declaration *elem_declaration,
+                         struct bt_declaration *elem_declaration,
                          struct declaration_scope *parent_scope)
 {
        struct declaration_sequence *sequence_declaration;
-       struct declaration *declaration;
+       struct bt_declaration *declaration;
 
        sequence_declaration = g_new(struct declaration_sequence, 1);
        declaration = &sequence_declaration->p;
@@ -126,7 +126,7 @@ struct declaration_sequence *
 }
 
 static
-struct bt_definition *_sequence_definition_new(struct declaration *declaration,
+struct bt_definition *_sequence_definition_new(struct bt_declaration *declaration,
                                struct definition_scope *parent_scope,
                                GQuark field_name, int index,
                                const char *root_name)
@@ -171,20 +171,9 @@ struct bt_definition *_sequence_definition_new(struct declaration *declaration,
        sequence->string = NULL;
        sequence->elems = NULL;
 
-       if (sequence_declaration->elem->id == CTF_TYPE_INTEGER) {
-               struct declaration_integer *integer_declaration =
-                       container_of(sequence_declaration->elem, struct declaration_integer, p);
-
-               if (integer_declaration->encoding == CTF_STRING_UTF8
-                     || integer_declaration->encoding == CTF_STRING_ASCII) {
-
-                       sequence->string = g_string_new("");
-
-                       if (integer_declaration->len == CHAR_BIT
-                           && integer_declaration->p.alignment == CHAR_BIT) {
-                               return &sequence->p;
-                       }
-               }
+       if (sequence_declaration->elem->id == CTF_TYPE_INTEGER &&
+                       bt_int_is_char(sequence_declaration->elem)) {
+               sequence->string = g_string_new("");
        }
 
        sequence->elems = g_ptr_array_new();
This page took 0.025418 seconds and 4 git commands to generate.