Re: memory pool?
On Nov 10, 10:54 am, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
Uli Kunkel <genija...@yahoo.com> writes:
I have a situation where I'm getting a picture from a camera
in small chunks. So the photo is a few MBytes and I have a
callback function that returns 1KB until it finishes
transfering the picture. Any suggestions or examples how
should I put a picture in one variable? I heard something
about using memory pools for this but I only need something
simple for this occasion. Could I use CString?
Not on comp.lang.c++. For CString, you should ask on comp.lang.c.
You really want to see him flames, don't you? :-)
Anytime you see a class whose name is prepended by a C, it's
probably something from MFC; it's a Microsoft convention,
anyway. So if he really wants to use CString for some reason, a
Microsoft group would be in order.
Of course, CString isn't any simpler than std::string.
Anyway thanks in advance for any suggestions.
typedef unsigned char byte;
const int KByte=1024;
const int MByte=1024*KByte;
const int few=6;
std::vector<byte> image(few*MByte,0);
Then you can receive copy small buffers into it:
I'm not too sure what he's trying to do, but it sounds to me
that what he probably wants os for the callback function to
append to a vector. In which case, he could initialize the
vector with reserve() if he knew the size in advance (but for
relatively small buffers like a couple of meg, this is probably
overkill). His callback function just does push_back (or
insert() at the end).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34