开发者

copy buffer contents to another buffer

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 (pMediaDat开发者_如何学Pythona->Size()) );

i want to copy pMediaData in buf1.

thanks


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() );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜