comp.lang.ada
 help / color / mirror / Atom feed
* Elegant 'realloc'?
@ 2003-07-31  9:57 Lutz Donnerhacke
  2003-07-31 14:42 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lutz Donnerhacke @ 2003-07-31  9:57 UTC (permalink / 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;



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

end of thread, other threads:[~2003-08-01  0:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31  9:57 Elegant 'realloc'? Lutz Donnerhacke
2003-07-31 14:42 ` 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

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