作者youhas (...)
看板CSSE
标题Re: [请益] realloc -- Aborted error
时间Fri Mar 3 20:00:33 2006
※ 引述《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
1F:推 temari:我想他应该是是在 linux 下写这段程式的... 03/03 20:48
2F:推 ledia:是因为看到 ElfW(Shdr) 吗 ^^? 03/04 11:10
3F:推 mahaw:~对的,我是在linux下写的~~ 03/06 18:40