comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus.rm.tsoh@maps.futureapps.de>
Subject: Re: Dynamically reallocated buffer
Date: Fri, 01 Jun 2007 13:32:19 +0200
Date: 2007-06-01T13:29:40+02:00	[thread overview]
Message-ID: <46600323$0$10199$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <1180679626.254857.59070@w5g2000hsg.googlegroups.com>

Maciej Sobczak wrote:

> For those of you who know C++ I need something like:
> 
> vector<unsigned char> buffer;
> // fill the buffer with push_back or insert at end
> // ...
> write_to_device(&buffer[0], buffer.size());
> 


I'd use references to normal arrays and if I wanted to be sure that
a program can rely on realloc() I'd consider a simple storage pool
using this OS function. (GNAT has System.Memory with ready made
bindings on some platforms.)

Then just call new Flex_Buffer(as needed). Possibly behind some
Container like interface (or Controlled and Reserve_Capacity in
Initialize).



  parent reply	other threads:[~2007-06-01 11:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-01  6:33 Dynamically reallocated buffer Maciej Sobczak
2007-06-01  7:15 ` anon
2007-06-01 13:04   ` Maciej Sobczak
2007-06-01  7:30 ` Dmitry A. Kazakov
2007-06-01 13:08   ` Maciej Sobczak
2007-06-01 11:32 ` Georg Bauhaus [this message]
2007-06-01 14:49 ` Matthew Heaney
2007-06-02 12:38   ` Stephen Leake
2007-06-03  9:52     ` Georg Bauhaus
2007-06-05  0:25       ` Stephen Leake
replies disabled

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