Reputation: 215
I have the contents of an http request in my buffer. I then define another buffer of the same size as the last one. And i need to copy the contents of the buffer to my new buffer. So the help i need is that how do i get to copy one buffer to another buffer.
I tried memcpy
but it is not working.
void TrivialMediaPlayer::DeliverMediaData(
int streamId,
bool bHasPriority,
ConstBufferSptr pMediaData)
What i want is to copy the contents of pMediaData
to a new buffer.
BufferSptr buf1 (new Buffer (pMediaData->Size()) );
i want to copy pMediaData
in buf1
.
thanks
Upvotes: 3
Views: 20207
Reputation: 1768
I am not sure what the exact code you write to copy from one StringSptr from another. But if you wanna
memcpy( (void*)buf1 , (void*)pMediaData , pMediaData.Size() );
You must make sure that you should defined the "void*" function in the BufferSptr class (seems like a class written by you) to convert your BufferSptr object to a real C pointer which point to the address of internal buffer.
Or, use some explicit call:
memcpy( buf1.data() , pMediaData.data() , pMediaData.Size() );
Upvotes: 7