Hi,
I'm new to this forum and was hoping someone could help me debug a sanity-questioning problem I'm having. Consider the following function declaration and call...
Code:
int encode_buffer(large_struct_t * gfp, const int buffer[16][2][1152],
int nsamples[16], unsigned char mp3buf[16][16384],
int mp3buf_size[16],
int num_frames_to_encode,
int mp3sizes[16]);
void my_func() {
int mp3sizes[16];
int mp3buf_size[16];
int Buffer[16][2][1152];
int num_frames_to_encode;
large_struct_t *gf;
unsigned char mp3buffer[16][16384];
int iread_arr[16];
...
encode_buffer(gf, Buffer, iread_arr, mp3buffer, mp3buf_size,
num_frames_to_encode, mp3sizes);
...
}
For some reason, I'm experiencing some corruption of the function parameters, once the function is executed. When I step through the execution, I can see that just before the function call, all the values being passed are sane values, but once I step inside the function, the values become muddled. With this specific configuration, I lose the first dimension of each array. The address of these values remains the same, but somehow their contents is altered in the function call. The scalar value (num_frames_to_encode) remains consistently correct.
I have also tried alternative function prototypes along the following lines:
Code:
int encode_buffer(large_struct_t * gfp, const int buffer[16][2][1152],
int nsamples[16], unsigned char *mp3buf[16],
int mp3buf_size[16],
int num_frames_to_encode,
int mp3sizes[16]);
Where the type of mp3 buf is "unsigned char *mp3buf[16]." In my mind, either of these prototypes should be fine (multidimensional arrays are represented as an array of pointers to an array, right?). I should note that this is part of a very large program, and doing simpler sanity checks reveal to me that at least the first prototype should be correct, given only this function and a call to it.
If anyone has any ideas or solutions, I would greatly appreciate hearing them! Thanks!