comp.lang.ada
 help / color / mirror / Atom feed
From: "Francesco Bochicchio" <bockman@virgilio.it>
Subject: renames and access
Date: Wed, 11 Feb 2004 19:15:02 GMT
Date: 2004-02-11T19:15:02+00:00	[thread overview]
Message-ID: <pan.2004.02.11.19.14.49.293492@virgilio.it> (raw)

Hi all,

I have a piece of code that does something like this:

type REC_T is record
	A : Integer;
	B : String(4)
end record;

type REC_PTR_T is access REC_T;
REC_PTR : REC_PTR_T := new REC_T;

A renames REC_PTR.A;
B renames REC_PTR.B;

At this point, I can use A and B as if they where simple 
variables. BUT, when I later reallocate the memory like this:

function REALLOCATE_MEMORY return REC_PTR_T;
REC_PTR := REALLOCATE_MEMORY(); -- Actually, the ability to reallocate is
                                -- the reason for all this  fuss.
				--

then A and B still points to the old memory, not at the one currently
pointed by REC_PTR.

Is this normal ??(I work with ObjectADA, did not try yet with GNAT)  
Is there any way to have the renames to automatically points to the new
memory?
If this turns impossible, what would be an equivalent solution? At the
moment, my bet is to turn the renames into access. Any better idea?

BACKGROUND : the reason for all this is that we are trying to add a
failover capability to a very old application of many thousand lines 
of code. Therefore, the 'critical variables' (one hundred or more) shall
be allocated in a special area of memory which is mirrored between the
primary machine and its backup, where  a copy of the application
runs in hot standby. The trick with the renames should have spared us from
changing every line of code referring to one of these variables.

Thanks for any hints you can give me.

Ciao
-----
FB  






             reply	other threads:[~2004-02-11 19:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-11 19:15 Francesco Bochicchio [this message]
2004-02-11 22:09 ` renames and access Randy Brukardt
2004-02-12  0:02 ` Robert A Duff
2004-02-12 18:36   ` Francesco Bochicchio
2004-02-13  8:30     ` Martin Dowie
2004-02-13 20:33     ` Robert I. Eachus
2004-02-12  2:32 ` Stephen Leake
2004-02-12 18:30   ` Francesco Bochicchio
2004-02-13 19:01     ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox