This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

butting two arrays

I have a project where data is received to array a, reformatted to array b, then reformatted to array c. The arrays are different sizes. The process is relevant as different parts of array b are reformatted to array c at different times.

There is a possibility that array a may overflow ever so slightly; however if it overflows into array c, it will not be a problem.

The question is:
can I 'trick' the linker to place array c immeddiately following array a in memory.

Thanx,

Erik

Parents
  • Further thoughts:

    1. Could you use a union, so that you're actually getting the compiler to some "overlaying?"

    2. Or something like this:

    U8 b[SIZE_A];
    {
       U8 a[SIZE_B];
       // get data into a[]
       :
    
       // format data from a[] into b[]
       :
    }
    {
       U8 c[SIZE_C];
       // reformat data from b[] into c[]
       :
    }
    By defining a[] and c[] in separate blocks, their "lifetimes" do not overlap, so the Linker can overlay them.

    I've assumed that your process is a[] --> b[] --> c[], so that the data in a[] is no longer required when you start processing b[] into c[] - but I could be wrong there?

Reply
  • Further thoughts:

    1. Could you use a union, so that you're actually getting the compiler to some "overlaying?"

    2. Or something like this:

    U8 b[SIZE_A];
    {
       U8 a[SIZE_B];
       // get data into a[]
       :
    
       // format data from a[] into b[]
       :
    }
    {
       U8 c[SIZE_C];
       // reformat data from b[] into c[]
       :
    }
    By defining a[] and c[] in separate blocks, their "lifetimes" do not overlap, so the Linker can overlay them.

    I've assumed that your process is a[] --> b[] --> c[], so that the data in a[] is no longer required when you start processing b[] into c[] - but I could be wrong there?

Children