Re: [請益] realloc -- Aborted error
※ 引述《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
推
03/03 20:48, , 1F
03/03 20:48, 1F
推
03/04 11:10, , 2F
03/04 11:10, 2F
推
03/06 18:40, , 3F
03/06 18:40, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
CSSE 近期熱門文章
PTT數位生活區 即時熱門文章