[Gambas-user] [Fwd: Gambas3 Pointers example] signal #6

Jussi Lahtinen jussi.lahtinen at ...626...
Mon Jan 10 20:54:12 CET 2011


>
> 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



More information about the User mailing list