-
December 19th, 2003, 04:46 AM
#1
Divide the buffer into chunks
Hi !!!
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.
UmaR
-
December 19th, 2003, 05:05 AM
#2
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.
Code:
char largeBuffer[128*1024];
char* chunk0 = &largeBuffer[0];
char* chunk1 = &largeBuffer[10*1024];
char* chunk2 = &largeBuffer[2*10*1024];
char* chunk3 = &largeBuffer[3*10*1024];
-
December 20th, 2003, 11:01 AM
#3
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.
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|