Q: Is this the correct way for memmove in reverse order? I'm trying to understand how does memmove work. I'm taking an example where I have data in memory in this manner.
Start at 0
First Memory Block(A) of size 10
Hence A->(0,10) where 0 being where it starts and 10 it's length.
Thus B-> (10,20)
     C-> (30,50)
     D-> (80,10)

Let's say that we have a variable X which records where can insert next which would be 90 in the example given above.
Now if I want to delete B, then I would like to move C and D to free space occupied by B.
input is input array.
So input array will look like having first 10 characters belonging to block A, next 20 belonging to block B etc.
This I think can be done using memmove as follows:
memmove(input+start(B),input+start(B)+length(B),X-(start(B)+length(B))

Now I want to try for reverse order.
So we start from behind
Start at 100
First memory block(A) of size 10
A-> (100,10) 100 is where it starts and 10 it's length
B-> (90,20)
C-> (70,50)
D-> (20,10) 

Similar to first example, let's say we have a variable X where we record where we can insert next. This would be 10 for the example in reverse order.
Now if I want to delete block B, then I would like C and D to overlap in B's space. This would be memmove in reverse order.
I think this can be done in this manner:
memmove(input+start(B)-(start(B)-length(B)-X),input+X,start(B)-length(B)-X)

As per Alex comment, I think I've not kept the correct ordering of data. Data would be like,
A->(90,10)
B->(70,20)
C->(40,30)
D->(20,20)
and X which would be D's starting address i.e at 20
Now if we want to delete B,memmove would look something like this.

memmove(input+X+length(B), input+X,start(B)-X)

Are there better ways to do this?
Note this is not for homework.

A: C and D occupy together 50+10=60, so why 20 in memmove(input+start(B), input+start(B)+length(B), 20)?
As for the other part, in C objects don't start with their last byte (the first byte is at the lowest address and the last byte at the highest). This part is confusing.
