-2
可能重複:
Pass a buffer by reference to other function「地址0x7f的出界」通過函數傳遞參數
當我調用該函數AST它節省了緩衝和緩衝區長度的數據,但我嘗試從十二月訪問這個指針,我可以打印* bufferlen但緩衝它是不可能的。
當我做臨時=緩衝區出現分段錯誤。並在調試器中,我看到緩衝區「地址0x7f越界」。如何從dec打印緩衝區?哪個是錯誤?
void ast(KOCTET *buffer,KUINT16 *bufferlen){
KOCTET *Bufferencode,*temp;
KUINT16 BufferSize=5000;
KUINT16 WritePos=0;
KUINT16 total_bytes;
Bufferencode=(KOCTET*)malloc(5000*sizeof(KOCTET));
memset(Bufferencode,0,sizeof(Bufferencode));
total_bytes = stream.CopyIntoBuffer(Bufferencode, BufferSize, WritePos);
buffer=Bufferencode;
*bufferlen=total_bytes;
int z=0;
temp=buffer;
while (z<(*bufferlen)){
printf(" %02X",(unsigned char)*temp);
temp++;
z++;
}
printf("\n");
}
void dec()
{
KOCTET *buffer,*temp;
KUINT16 *bufferlen;
ast_process_048(buffer,bufferlen);
int z=0;
temp=buffer;
while (z<(*bufferlen)){
printf(" %02X",(unsigned char)*temp);
temp++;
z++;
}
printf("\n");
}
你昨天問過這個。 http://stackoverflow.com/questions/11846171/pass-a-buffer-by-reference-to-other-function – cnicutar 2012-08-08 07:58:29
它是相似的,但我已經改變了我的程序的結構,它沒有通過參數繼續。 – dani 2012-08-08 08:10:32