MODULE T18;

IMPORT FIO, Storage, SYSTEM, Strings, MemUtils, libc;
IMPORT NumberIO;

TYPE
    abufType            = RECORD
                            b   : SYSTEM.ADDRESS;
                            len : CARDINAL;
                          END;
    abufTypePtr         = POINTER TO abufType;


VAR
    (* abuf       : abufType; *)
    abufPtr     : abufTypePtr;
    str         : ARRAY [0..100] OF CHAR;
    i           : CARDINAL;


BEGIN
    Storage.ALLOCATE(abufPtr,SYSTEM.TSIZE(abufType) );
    str := " Bonjour les petits amis!";
    Storage.ALLOCATE(abufPtr^.b, Strings.Length(str));
    
    MemUtils.MemCopy(SYSTEM.ADR(str),Strings.Length(str), abufPtr^.b);  
    abufPtr^.len := Strings.Length(str);
    libc.write(FIO.StdOut,abufPtr^.b,abufPtr^.len);
    
    Storage.DEALLOCATE(abufPtr^.b, Strings.Length(str));
    Storage.DEALLOCATE(abufPtr,SYSTEM.TSIZE(abufType));
END T18.