comp.lang.ada
 help / color / mirror / Atom feed
* renames and access
@ 2004-02-11 19:15 Francesco Bochicchio
  2004-02-11 22:09 ` Randy Brukardt
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Francesco Bochicchio @ 2004-02-11 19:15 UTC (permalink / 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  






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-02-13 20:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-11 19:15 renames and access Francesco Bochicchio
2004-02-11 22:09 ` 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

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