From e39c574c21b312dbda019a59392329b3bfbcf56b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 9 Nov 2015 23:02:23 -0800 Subject: 2414 - clear memory leaks --- 059generic_recipe.cc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to '059generic_recipe.cc') diff --git a/059generic_recipe.cc b/059generic_recipe.cc index d4e7401f..c2789297 100644 --- a/059generic_recipe.cc +++ b/059generic_recipe.cc @@ -140,9 +140,13 @@ recipe_ordinal new_variant(recipe_ordinal exemplar, const instruction& inst) { // work of the check_types_by_name transform while supporting type-ingredients. compute_type_names(new_recipe); // that gives enough information to replace type-ingredients with concrete types - map mappings; - compute_type_ingredient_mappings(get(Recipe, exemplar), inst, mappings); - replace_type_ingredients(new_recipe, mappings); + { + map mappings; + compute_type_ingredient_mappings(get(Recipe, exemplar), inst, mappings); + replace_type_ingredients(new_recipe, mappings); + for (map::iterator p = mappings.begin(); p != mappings.end(); ++p) + delete p->second; + } ensure_all_concrete_types(new_recipe); // finally, perform all transforms on the new specialization for (long long int t = 0; t < SIZE(Transform); ++t) { @@ -386,4 +390,22 @@ recipe bar x:number -> result:address:foo:_t [ +mem: storing 0 in location 12 +mem: storing 0 in location 13 -# todo: container after generic recipe containing 'new' +:(scenario generic_recipe_handles_generic_new_ingredient_2) +recipe main [ + 1:address:foo:point <- bar 3 + 11:foo:point <- copy *1:address:foo:point +] +recipe bar x:number -> result:address:foo:_t [ + local-scope + load-ingredients + # new refers to _t in its ingredient *value* + result <- new {(foo _t) : type} +] +# container defined after use +container foo:_t [ + x:_t + y:number +] ++mem: storing 0 in location 11 ++mem: storing 0 in location 12 ++mem: storing 0 in location 13 -- cgit 1.4.1-2-gfad0