From: news01+Steven.Murdoch@cl.cam.ac.uk (Steven Murdoch)
Subject: Size of a pointer to a tagged record
Date: 4 Dec 2002 14:01:22 GMT
Date: 2002-12-04T14:01:22+00:00 [thread overview]
Message-ID: <asl1ri$l1t$1@pegasus.csx.cam.ac.uk> (raw)
I am writing a binding to the Lua (http://www.lua.org/)
scripting language (which is written in C). One thing I
need to do is store a pointer to a tagged record in a
memory location allocated by malloc. For this reason I need
to know the size.
If a pointer to a tagged record is equivalent to a
System.Address then I can store this in a memory location
of sizeof(void *), however if the tag is stored in the
pointer rather than the record then I would need to
allocate space for the tag as well.
If a pointer to a tagged record is equivalent to a
System.Address then I would use the following code:
--
type Parameter is tagged private;
type Parameter_Access is access all Parameter'Class;
package Convert is new
System.Address_To_Access_Conversions(Parameter);
addr: System.Address;
param: Parameter_Access;
addr:=Get_Void_Pointer; --Void* from C
param:=Parameter_Access(User_Data_Convert.To_Pointer(Address));
--
At the end of this code I would use param as a normal pointer
to a tagged record. Does this look OK? Is there a better way
to achieve the same thing.
I am using GNAT 3.13p but I would like the code to be as
cross platform/compiler as possible.
Thanks in advance,
Steven Murdoch.
next reply other threads:[~2002-12-04 14:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-04 14:01 Steven Murdoch [this message]
2002-12-04 15:16 ` Size of a pointer to a tagged record Robert A Duff
2002-12-04 15:44 ` Steven Murdoch
2002-12-04 17:17 ` Robert A Duff
2002-12-04 17:56 ` Steven Murdoch
2002-12-04 19:10 ` Robert A Duff
2002-12-07 6:55 ` David Thompson
2002-12-04 20:27 ` Simon Wright
2002-12-04 18:11 ` tmoran
2002-12-04 17:05 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox