So I’m in the need to translate a C library to pure java, so far its looking good, but I’m stuck here.
Can someone explain to me what does the following pointer is for?
double *DTimeSigBuf[MAX_TIME_CHANNELS];
Ok I know it is a double type pointer named DTimeSigBuf, but whats that in the brackets? also MAX_TIME_CHANNELS is defined in the h file as:
#define MAX_TIME_CHANNELS 2
then in the code this constant value changes, like its pointing somewhere else, but I dont know what does exactly means. is it equivalent to say:
double *DTimeSigBuf = MAX_TIME_CHANNELS;
if I recall well there was something similar in assembler, like: mov [BX], CL called Indirect addressing mode register, does this have anything to do with this? I know I might be completly lost! because as the title says, I’m a java programmer.
And the other question, what is the effect of doing this:
DTimeSigBuf[chanNum] = (double*)malloc(block_size_samples*sizeof(double));
Where block_size_samples is int and chanNum is an for iterator variable?
Please help! I sware I’ve been googling the whole time.
Thanks folks 🙂
DTimeSigBufis an array of pointers to typedouble. This could be thought of as an array of arrays of typedouble.could be thought of as
The line
is allocating memory for
block_size_samplesnumber of variables of typedoubleto be placed in the array pointed at byDTimeSigBuf[chanNum].For example:
If
block_size_samplesis4andchanNumis1, you could think of it this way: