我想請教個困擾已久的問題…這問題讓我很久沒進度了。拜託有人能指點一下。
我首先有用到二個struct定義如下:
struct obj_section{
int index; ElfW(Shdr) header;
const char *name;
char *contents;
struct obj_section *next; };
struct obj_file{
...略
struct obj_section **sections;
...略
};
在程式的某處我已經對sections的空間做malloc了。
但是我在處理的過程中,又必須要動態的調整sections的空間大小,所以
我用realloc function,可是…不知道怎麼回事,執行的時候一直aborted…
出問題的這行如下:
struct obj_section *obj_create_alloced_section_first( struct obj_file *f, const char *name,unsigned long align, unsigned long size )
{
…略
f->sections = realloc( f->sections,(newidx+1)*sizeof(sec) );
…略
}
出問題的又是第二個,就是括號裡頭的,f->sections,如果這個欄位改0,那OK,可以run過去,但這樣…又不是我要的。
另外我在cygwin下跑程式,這邊又只丟個Aborted給我…
拜託有任何idea的仁兄能給我點意見,感謝。