当我说:“返回的变量是 NULL。”时,我的意思是它返回一个包含两个指针和they == NULL
.
struct LandR_8
{
unsigned char *L; // For L channel.
unsigned char *R; // For R channel.
}; // These pointers point to the allocated memory.
struct LandR_8 LRChannels_8;
我的功能:
struct LandR_8 sepChannels_8( unsigned char *smp, unsigned char *L, unsigned char *R, unsigned long N, struct LandR_8 LRChannels )
{
int i;
L = malloc(N / 2);
R = malloc(N / 2);
for ( i = 0; i < (N / 2) ; i++ ) // separating
{
L[i] = smp[2 * i + 0];
R[i] = smp[2 * i + 1];
}
// L and R don't need `free()`.
return LRChannels;
}
LRChannels
返回类型的变量struct LandR
:
我这样称呼我的函数:
LRC_8 = sepChannels_8( ptrSamples_8, ptrSamples_8_L, ptrSamples_8_R, n, LRChannels_8 );
问题是使用该功能后LRC_8.L == NULL
。
为什么会这样?