精華區beta CSSE 關於我們 聯絡資訊
※ 引述《mahaw (我要賭本!!)》之銘言: : 我想請教個困擾已久的問題…這問題讓我很久沒進度了。拜託有人能指點一下。 : 我首先有用到二個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 : { : struct obj_section *sec; : …略 : f->sections = realloc( f->sections,(newidx+1)*sizeof(sec) ); : …略 : } : 出問題的又是第二個,就是括號裡頭的,f->sections,如果這個欄位改0,那OK,可以 : run過去,但這樣…又不是我要的。 我要保留住先前的值… : 拜託有任何idea的仁兄能給我點意見,感謝。 : 是空間不夠分了嗎…? 請問你是用VC++ 6.0嗎? 如果是的話 不妨裝sp6試試 Q225099 FIX: Memory Access Violation Caused by Repeated Reallocs for Small Blocks (Q225099) Under certain circumstances, using the Realloc function in a small memory block (if the total small-block memory pool exceeds 16 MB) causes access violation with the Visual C++ 6.0 small-block allocator. http://www.kbalertz.com/kb_Q225099.aspx -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.101.228
temari:我想他應該是是在 linux 下寫這段程式的... 03/03 20:48
ledia:是因為看到 ElfW(Shdr) 嗎 ^^? 03/04 11:10
mahaw:~對的,我是在linux下寫的~~ 03/06 18:40