]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: fix valgrind-reported errors.
[ocean] / csrc / oceani.mdc
index 07caefafca523bf1014752bf1cc228f0f7689a72..02968bb473926333f3341ed78663d24d2b9144dd 100644 (file)
@@ -3430,26 +3430,31 @@ make a copy of an array with controllable depth.
                $0->array.member = $<4;
                $0->array.vsize = NULL;
                {
+               struct parse_context *c = config2context(config);
                char tail[3];
                mpq_t num;
                if (number_parse(num, tail, $2.txt) == 0)
-                       tok_err(config2context(config), "error: unrecognised number", &$2);
+                       tok_err(c, "error: unrecognised number", &$2);
                else if (tail[0])
-                       tok_err(config2context(config), "error: unsupported number suffix", &$2);
+                       tok_err(c, "error: unsupported number suffix", &$2);
                else {
                        $0->array.size = mpz_get_ui(mpq_numref(num));
                        if (mpz_cmp_ui(mpq_denref(num), 1) != 0) {
-                               tok_err(config2context(config), "error: array size must be an integer",
+                               tok_err(c, "error: array size must be an integer",
                                        &$2);
                        } else if (mpz_cmp_ui(mpq_numref(num), 1UL << 30) >= 0)
-                               tok_err(config2context(config), "error: array size is too large",
+                               tok_err(c, "error: array size is too large",
                                        &$2);
+                       mpq_clear(num);
                }
+               $0->next= c->anon_typelist;
+               c->anon_typelist = $0;
                }
        }$
 
        | [ IDENTIFIER ] Type ${ {
-               struct variable *v = var_ref(config2context(config), $2.txt);
+               struct parse_context *c = config2context(config);
+               struct variable *v = var_ref(c, $2.txt);
 
                if (!v)
                        tok_err(config2context(config), "error: name undeclared", &$2);
@@ -3461,8 +3466,23 @@ make a copy of an array with controllable depth.
                $0->array.member = $<4;
                $0->array.size = 0;
                $0->array.vsize = v;
+               $0->next= c->anon_typelist;
+               c->anon_typelist = $0;
        } }$
 
+###### parse context
+
+       struct type *anon_typelist;
+
+###### free context types
+
+       while (context.anon_typelist) {
+               struct type *t = context.anon_typelist;
+
+               context.anon_typelist = t->next;
+               free(t);
+       }
+
 ###### Binode types
        Index,