Jing Gloria wrote:
I have searched the mailing list archive and have not found the information that I needed. I hope somebody here can provide the answers or point me to where I can find them.
I am porting existing code from a RISC/SunOS system to an Intel(PC)/Solaris7 system. I am using gpc version 20010623, based on gcc-2.95.2 19991024 (release).
In the program below, GPC and the RISC/SunOS compiler do not produce the same results in the NEW call: New(point3, No). GPC will allocate the total size (168 bytes) of the record (ItemData) and will initialize the field 'tag' to 1 (which is NO in the enumeration type Answer). In the SunOS compiler, this same statement will allocate memory (92 bytes) to accomodate the following fields for ItemData: number, tag, A_string, False_entries) and will NOT initialize the tag field.
How do I get GPC to compile the NEW call in the same way as the SunOS Pascal compiler? BTW, the Dispose call in SunOS Pascal passes both pointer and size (based on the second parameter to the dispose call) to the Dispose routine.
The GPC preinitialization of the variant tag should not affect anything, unless you rely on it. Similarly passing of variant size in the dispose call, since how the system keeps track of allocation size is up to the implementor. Passing the size allows some very simplistic allocation schemes to be used which I don't believe is happening here - i.e. AFAIK gpc is using the underlying C malloc/free system.
Failure to cut allocation size back to that required is a quality of implementation detail, and again does not affect standards compliance. I am sorry to hear GPC does not do this. I suggest you check out the new 2.1 version, which was just released, and may do this reduction. In todays world of monstrous virtual memory spaces it is less important than it used to be.