Boost logo

Boost Users :

From: Blake D (BlakeTNC_at_[hidden])
Date: 2003-03-24 20:22:16


Hello everyone :)

I am a new boost user, and I'm trying to convert a large project to use the
smart pointers. I have a use for shared_array buy the memcpy line from the
following code snippet(, and all memcpy's) throw an exception with the
shared_arrays and I don't know why. Am I doing something obvious wrong?

Thank you,
Blake

//------------------class declaration
snippet---------------------------------
// Pointer to the packet
boost::shared_array<uint8> p_data;
// uint8 * p_data; <--- old working line

//------------------class cpp file snippet---------------------------------
// copy Constructor
c_Packet::c_Packet (const c_Packet & r_packet)
{
data_length = r_packet.data_length;

boost::shared_array<uint8> p_data(new uint8[data_length]);
// p_data = new uint8[data_length]; <--- old working line

// Copy data from our source object to this object
memcpy(p_data.get(), r_packet.p_data.get(), data_length); // <- throws
exception!
// memcpy(p_data, r_packet.p_data, data_length); <---- old working line

#ifdef DO_DEBUG
// cout << "packet copy constructor called" << endl ;
#endif // DO_DEBUG
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net