I'm with few questions about how to implement a function for adding a byte matrix to some "pattern" structure vector.
Here is my code structure:
struct pattern<br>
{
byte** map;
int size;
};
struct pattern* pvec;
int patterns = 0;
void add_pattern(byte** map, int size)
{
struct pattern p;
int i;
p.size = size;
p.map = (byte**) malloc(p.size * sizeof(byte*));
for (i = 0; i < size; i++)
p.map[i] = (byte*) malloc(4 * sizeof(byte));
p.map = map;
pvec[patterns] = p;
patterns++;
}
And an example of a byte matrix:
{
{B1000,B0000,B0000,B0000},
{B0100,B0000,B0000,B0000},
{B0010,B0000,B0000,B0000},
{B0001,B0000,B0000,B0000},
{B0000,B0001,B0000,B0000},
{B0000,B0000,B0001,B0000},
{B0000,B0000,B0000,B0001},
{B0000,B0000,B0000,B0010},
{B0000,B0000,B0000,B0100},
{B0000,B0000,B0000,B1000},
{B0000,B0000,B1000,B0000},
{B0000,B1000,B0000,B0000}
}
But I think this isn't a good way to do that, because I don't know exactly how to send this byte** argument to the function, considering that I have some patterns with few "rows of bytes" than others.
How can I do this in another way? Maybe sending a pre-built pattern structure as an argument?