gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] double free or corruption with pointers


From: gaius
Subject: Re: [Gm2] double free or corruption with pointers
Date: Tue, 03 Aug 2010 06:43:17 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Martin Kalbfuß <address@hidden> writes:

> Many Thanks,
>
> MODULE array;
>
> IMPORT Storage, SYSTEM, STextIO, SWholeIO;
>
> CONST maxArraySize = 32768;
> TYPE DynArrayPtr = POINTER TO ARRAY[0..maxArraySize] OF INTEGER;
> VAR myArray : DynArrayPtr;
> VAR runtimeSize : INTEGER;
>
> BEGIN
>      runtimeSize := 5;
>      Storage.ALLOCATE(myArray, SYSTEM.TSIZE(INTEGER)*runtimeSize);
>      myArray^[3] := 5;
>      SWholeIO.WriteInt(myArray^[3], 1);
>      STextIO.WriteLn();         
>      Storage.DEALLOCATE(myArray,SYSTEM.TSIZE(INTEGER)*runtimeSize);     
> END array.
>
> This works like I need it. But the boundaries aren't checked any longer
> like they are for static arrays. :-(

Hi Martin,

ahh I think you need VLAs which are scheduled to arrive post 1.0 :-).
In the meantime - it maybe worth having a look at
gm2/gm2-libs/Indexing.def which gives you a dynamic array of pointers
with index checking.

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]