Oh, I forgot to mention, that when you do "Free(pPointer)", Gambas doesn't
occupy that memory address for you anymore.
And therefore some other process can write something to it, and result is
not necessarily human readable.

Jussi


On Mon, Jan 10, 2011 at 21:54, Jussi Lahtinen <jussi.lahti...@gmail.com>wrote:

>
>
>> first print gives the correct output
>> /home/user/Documents/Development/Gambas3/Pointers7
>>
>> and the second after Free(pFunc) gives this
>> �s&^...@^@^...@^@^...@^@^...@^@^...@ocuments/Development/Gambas3/Pointers7
>>
>
>
> This has something to do how strings are handled in Gambas, I don't think
> this is bug.
>
> Some lines of simplified example code and explanation:
>
> Dim pPointer As Pointer
> Dim hMemory As Stream
> Dim s As String
>
> pPointer = Alloc(4) ' Alloc for four characters, last one means 'end of
> string'.
> hMemory = Memory pPointer For Write
> Write #hMemory, Asc("a") As Byte
> Write #hMemory, Asc("b") As Byte
> Write #hMemory, Asc("c") As Byte
> Write #hMemory, Asc("\0") As Byte
>
> s = Str@(pPointer) ' This associates address to variable. Ie, in address
> pPointer is content of this string.
>
> Print s ' This will print out; "abc"
>
> Seek #hMemory, 0
> Write #hMemory, Asc("x") As Byte ' These two lines will access to address
> pPointer and change first character in there.
>
> Print s ' Therefore string changes to "xbc". Variable 's' is just
> representation of content in some (in this case pPointer) address.
>
>
>
>
>>
>> b) if i use Free(pBuf)
>> i get signal #6
>>
>
> I don't think this should happen... Benoit?
>
>
>
>
>> here i get correct results
>> but if i use Free(pFunc) i get signal #11
>>
>
> This shouldn't happen, it is bug.
> However I couldn't reproduce it with Gambas 3 rev 3451,
> but I got signal 6 from it.
>
>
> Jussi
>
>
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to