Solving data alignment issue

I have function A that only spits out arbitrary amount of byte (on range of 0x10 to 0x80), and function B that allows me to pass data only in 0x100 byte.

The solution that I could think of is an array that contains value from function A, it will concat the data as time goes until length of 0x100 is reached, call function B and pass 0x100 byte of data. Once function B finishes, shift the data in array via memcpy (so value from 0x100 index now starts from 0x0). And goes back to function A to get more data.

But I think this would be inefficient due to memcpy operation. Perhaps there is a way to solve this issue more efficiently? Or is there a term for this issue/solution that I could look for?
memcpy is one of the simplest, and most optimised operations you can perform.

And the amounts you're copying are not that large.

Make something that works, and then profile it.
You are right. I was overthinking that there is other way to implement this. I googled on memcpy and it seems to be one of the more efficient methods to copy blocks of memory. Thank you.
is this a place where memmove would do it better? mememove safely moves data around in overlapping blocks, for example if you want to get rid of the first element in an array by moving all the others up one spot.
You are right jonnin. I used memmove at the end and it works well for this implementation. Thank you :)
Last edited on
Topic archived. No new replies allowed.