December 19th, 2003, 04:46 AM
Divide the buffer into chunks
I wana divide a buffer into small size buffers..
As an example ...
I have a buffer of length 128k and i want to divide the buffer into 10k size.
One way is .. Read the data into an char array ... and then byte by byte get the data and copy to buffer...
Is there some good way or any method availabe .. in c library.
December 19th, 2003, 05:05 AM
Is there really a need to divide the buffer into smaller chunks? Without allocation new memory and copying data, you can still logically treat the buffer as separate chunks.
char* chunk0 = &largeBuffer;
char* chunk1 = &largeBuffer[10*1024];
char* chunk2 = &largeBuffer[2*10*1024];
char* chunk3 = &largeBuffer[3*10*1024];
December 20th, 2003, 11:01 AM
why do you need an intermediate char array?
your buffer itself should(can) be a char array.
memcpy() is a better choice unless the data is streaming in.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.