1. Пользуйтесь тегами кода. - [code] ... [/code] 2. Точно указывайте язык, название и версию компилятора (интерпретатора). 3. Название темы должно быть информативным. В описании темы указываем язык!!!
Новые вопросы - какая функция определяет наличие или отсутствие утечек памяти? Я скачал ВинАДУ, поставил, как подключить пакет, содержащий заголовки виндовых библиотек? with ADA.Windows не рабтает, нет такого пакета.
Хм... А чего ты вручную организуешь циклы по контейнерам, вместо того ,чтоб воспользоваться готовыми? Вот тут, например:
Цитата
procedure Del_Tree(T: in out aFunc_Tree) is
procedure Del_Childs(v: Func_Tree_Vectors.Vector) is use Func_Tree_Vectors; T: aFunc_Tree; begin for i in First_Index(v) .. Last_Index(v) loop T := Element(v, i); Del_Tree(T); end loop; end;
begin if T /= null then case T.Kind is when Operator | Func => Del_Childs(T.Childs); when others => null; end case; Free(T); T := null; end if; end;
Да и еще я где-то видел цикл по всему контейнеру... Можно же сделать так:
procedure Del_Tree(T: in out aFunc_Tree) is
procedure Del_Childs(C : Func_Tree_Vectors.Cursor) is T : aFunc_Tree := Element ( C ); begin Del_Tree (T); end Del_Childs;
begin if T /= null then case T.Kind is when Operator | Func => T.Childs.Iterate (Del_Childs'Access); when others => null; end case; Free(T); T := null; -- Это можно не делать end if; end;
Почему T := null можно не делать? Это будет гарантированно сделано в Unchecked_Deallocation:
Цитата(Ada RM 13.11.2)
Given an instance of Unchecked_Deallocation declared as follows:
procedure Free is new Ada.Unchecked_Deallocation(object_subtype_name, access_to_variable_subtype_name);
Procedure Free has the following effect: 1. After executing Free(X), the value of X is null. 2. Free(X), when X is already equal to null, has no effect.