comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Elegant 'realloc'?
Date: Thu, 31 Jul 2003 09:57:51 +0000 (UTC)
Date: 2003-07-31T09:57:51+00:00	[thread overview]
Message-ID: <slrnbihq0e.2j7.lutz@taranis.iks-jena.de> (raw)

When dealing with dynamically allocated variable length arrays, the
allocated space might change. Is there a common idiom to simulate an
'realloc' (especially shrinking) other than, allocate, copy, free?

   declare
      procedure Free is new Unchecked_Deallocation(T_Array, T_Array_Access);
      oldp : constant T_Array_Access := current.field;
   begin
      current.field := new T_Array'(oldp(oldp'First .. current.last));
      Free(oldp);
   end;



             reply	other threads:[~2003-07-31  9:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-31  9:57 Lutz Donnerhacke [this message]
2003-07-31 14:42 ` Elegant 'realloc'? Matthew Heaney
2003-07-31 14:59   ` Lutz Donnerhacke
2003-07-31 16:50     ` Matthew Heaney
2003-07-31 16:35 ` Nick Roberts
2003-08-01  0:01 ` Robert I. Eachus
replies disabled

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