繁体   English   中英

c - const char *和char * casting(ADPCM解码)

[英]c - const char* and char* casting (ADPCM decoding)

这是objective-c姐妹问题,它可能提供一些见解: c和objective-c - const char *和char *

我正在做以下事情:

g_ADPCMstate.valprev=32767;
g_ADPCMstate.index=0;


const char *modulatedBytes1 = {0xca,0x82,0x00,0x00,0x80,0x80,0x80,0x80};
char *modulatedBytes =  (char *)modulatedBytes1;
unsigned int moduleatedLength = 8;
short *decompressedBytes = NULL;

adpcm_decoder(modulatedBytes, decompressedBytes, moduleatedLength, &g_ADPCMstate);

函数声明是:

void      
adpcm_decoder(indata, outdata, len, state)      
    char indata[];      
    short outdata[];      
    int len;      
    struct adpcm_state *state; 

g_ADPCMstate是adpcm_state结构的全局实例变量。 http://codepad.org/5vyd0CXA是完整的代码。 *outp++ = valprev;时函数崩溃*outp++ = valprev; 发生了,我从我的调试器得到一个BAD ACCESS语句。 outp是指向outData的指针,而valprev是一个long。

问题必须在于我对指针以及modulatedBytes和/或decompressedBytes理解

我对C和低级概念了解甚少。 我希望能够深入了解我的问题。

你传递short *decompressedBytes = NULL; 作为adpcm_decoder()outdata参数,然后尝试取消引用它。 你忘记分配decompressedBytes吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM