My unsafe method accepts a collection byte[]s. All of these byte[]are the same size.
I need to iterate over all of them, looking for specific patterns. The search essentially has a reinterpret casting style: for each offset, I need to consider the value as if it were float, double, short, int, etc. Therefore, we obtain byte*for each input byte[]and its increment at each iteration seems natural.
Unfortunately, I cannot find a way to create a collection byte*- or, more specifically, initialize it from a set of arrays. Any ideas?
Here is a somewhat contrived version of the task:
static unsafe void SearchIteration(List<byte[]> arrays, byte[] resultArr)
{
fixed (byte* resultFix = resultArr)
{
byte* resultPtr = resultFix;
byte*[] pointers = new byte*[arrays.Count];
<some code to fix all the arrays and store the pointers in "pointers">
int remaining = resultArr.Length;
while (remaining > 0)
{
<look at resultPtr and each of the pointers and update *resultPtr>
remaining--;
for (int i = 0; i < pointers.Length; i++)
pointers[i]++;
}
}
}
, , pointers arrays, , GC .