31 Oct
2006
31 Oct
'06
2:33 p.m.
On Tue, 2006-10-31 at 06:49 -0500, Nat Goodspeed wrote:
[Nat] Have you tried using a std::vector<unsigned char>? You can get a pointer to the first byte in the vector by &myVector[0]. Then std::vector takes care of all the rest for you -- including allocation, cleanup and the STL container support.
So the functions would be like: // present_pos is an std::vectorboost::uint8_t::iterator to the // where the reading will start. // // dest_addr_ptr is where to write in memory // // length is how many bytes to read. void read ( boost::uint8_t* dest_addr_ptr, boost::uint32_t const& length ) { if ( present_pos + length > data.end() ) { // ERROR } memcpy ( dest_addr_ptr, *(*present_pos), length; } Was this what you had in mind? Stephen