ConsoleTom
Member
Hi !
I just want to ensure myself if this construction is ok:
A Struct:
struct samples
{
unsigned short * pSample[8];
unsigned int nSampleLen; /* you see right - 8 samples with the same size */
};
struct samples Sampleset[31];
<now i store in Sampleset[0-31].nSampleLen the size of samples>
Now i allocate memory -like this ?
for (i=0;i1;i++)
{
for(j=0;j<8;j++)
{
SampleSet.pSample[j] = gm_malloc(sizeof(unsigned short)*SampleSet .nSampleLen)
}
}
How can i store data in the memory i allocated ? For example: how would i store these values. 00, 15000, 14, 20 in the mem allocated: Sampleset[3].pSample[2] ?
I would think like this:
*(Sampleset[3].pSample[2] + 0) = 00;
*(Sampleset[3].pSample[2] + 1) = 15000;
*(Sampleset[3].pSample[2] + 2) = 14;
*(Sampleset[3].pSample[2] + 3) = 20;
Anything i forgot ?
Greetings
Tobias
I just want to ensure myself if this construction is ok:
A Struct:
struct samples
{
unsigned short * pSample[8];
unsigned int nSampleLen; /* you see right - 8 samples with the same size */
};
struct samples Sampleset[31];
<now i store in Sampleset[0-31].nSampleLen the size of samples>
Now i allocate memory -like this ?
for (i=0;i1;i++)
{
for(j=0;j<8;j++)
{
SampleSet.pSample[j] = gm_malloc(sizeof(unsigned short)*SampleSet .nSampleLen)
}
}
How can i store data in the memory i allocated ? For example: how would i store these values. 00, 15000, 14, 20 in the mem allocated: Sampleset[3].pSample[2] ?
I would think like this:
*(Sampleset[3].pSample[2] + 0) = 00;
*(Sampleset[3].pSample[2] + 1) = 15000;
*(Sampleset[3].pSample[2] + 2) = 14;
*(Sampleset[3].pSample[2] + 3) = 20;
Anything i forgot ?
Greetings
Tobias