P
Pushker Pradhan
I have a function which should allocate memory, initialize it to some values
and return the address of the initialized memory to the calling function.
void getWaveletCoeffs(float *ld, float *hd, int *filterLen)
{
ld = (float*)malloc(2*SZFLOAT);
hd = (float*)malloc(2*SZFLOAT);
*ld++ = 0.7071;
*ld-- = 0.7071;
*hd++ = -0.7071;
*hd-- = 0.7071;
*filterLen = 2;
}
In main() I have:
float *ld = NULL;
float *hd = NULL;
getWaveletCoeffs(&ld, &hd, &filterlen);
But in main() ld and hd are still NULL, I even tried
getWaveletCoeffs(ld, hd, &filterlen);
But it returns address of some invalid memory. What is the correct way of
passing the args so that I get back the correct addresses?
and return the address of the initialized memory to the calling function.
void getWaveletCoeffs(float *ld, float *hd, int *filterLen)
{
ld = (float*)malloc(2*SZFLOAT);
hd = (float*)malloc(2*SZFLOAT);
*ld++ = 0.7071;
*ld-- = 0.7071;
*hd++ = -0.7071;
*hd-- = 0.7071;
*filterLen = 2;
}
In main() I have:
float *ld = NULL;
float *hd = NULL;
getWaveletCoeffs(&ld, &hd, &filterlen);
But in main() ld and hd are still NULL, I even tried
getWaveletCoeffs(ld, hd, &filterlen);
But it returns address of some invalid memory. What is the correct way of
passing the args so that I get back the correct addresses?