-- -- Declarations for string stack. -- with Ada.Unchecked_Deallocation; package body SStack is -- Creator. function SDat(S: String) return StrStackData is RetVal: StrStackData; begin RetVal.V := new String'(S); return RetVal; end SDat; -- Extractor. function SValue(R: StrStackData) return String is begin return R.V.all; end SValue; -- Initialize a new object. Just gets the null pointer. procedure Initialize(SR: in out StrStackData) is begin SR.V := null; end Initialize; -- After assignment, turn the copy of the pointer into a real copy. procedure Adjust(SR: in out StrStackData) is begin SR.V := new String'(SR.V.all); end Adjust; -- When destroyed, free the space. procedure Finalize(SR: in out StrStackData) is procedure Free is new Ada.Unchecked_Deallocation(String, SPtr); begin Free(SR.V); end Finalize; end SStack;