[Gambas-user] Object.SizeOf(array) = 40
Ru Vuott
vuott at ...325...
Sun Mar 20 03:03:11 CET 2016
Yes, I know that does not represent the quantity of array contents.
> Why do you care with that?
To better understand via source code how Gambas's done.
For example:
Public Sub Main()
Dim bb As Byte[] = [11, 22, 33, 44]
Dim p1, p2 As Pointer
Dim s As String
Dim i As Integer
Dim l As Long
' Does it go in CARRAY Structure of gbx_c_array.h ?....
p1 = Object.Address(bb)
' ...in CARRAY->Object->Class->char *name ?
s = String@(Pointer@(Pointer@(p1) + 24))
Print s
' ...in CARRAY->int size ?
i = Int@(p1 + 16)
Print "\nSize of array type: "; i; " byte"
' ...in CARRAY->int count ?
i = Int@(p1 + 20)
Print "Number of array elements: "; i
' ...in CARRAY->TYPE type ?
l = Long@(p1 + 24)
Print "Type of array values: "; l
' ...in CARRAY->void *data ?
p2 = Pointer@(p1 + 32)
Print "\nArray contains these values:"
For i = 0 To bb.Max
Print Byte@(p2 + i),
Next
End
regards
vuott
--------------------------------------------
Dom 20/3/16, Benoît Minisini <gambas at ...1...> ha scritto:
Oggetto: Re: [Gambas-user] Object.SizeOf(array) = 40
A: "Ru Vuott" <vuott at ...325...>, "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
Data: Domenica 20 marzo 2016, 01:45
Le 20/03/2016 01:38, Ru
Vuott a écrit :
> Hello......
>
>
*********************************************
> Public Sub Main()
>
> Dim bb As Byte[] = [1, 2, 3, 4]
>
> Print
Object.SizeOf(bb)
>
>
End
>
*********************************************
>
> Object.SizeOf()
method return 40 byte.
>
> Why ?
>
> What is the source structure 40 bytes
long?
>
> Maybe
"GB_ARRAY_BASE" in "gambas.h" ?
>
> Regards
> vuott
>
It's not the size of the
array contents, it's the size of the object in
memory. Why do you care with that?
--
Benoît
Minisini
More information about the User
mailing list