Boy, do I feel stupid. Thanks, that was the problem exactly, just needed a fresh pair of eyes. On Wednesday 15 October 2003 07:18 pm, Tony Wetmore wrote: > Joseph, > > When allocating (or re-allocating) memory for block_order_log.blockID, > you allocate memory based on the size of the block_order_log_t > structure, even though blockID points to type blk_t. I do not know if > that is correct behavior, or if it might be at the heart of your > problem. > > If your intent is to store an array of blk_t objects pointed to by > blockID, this could very well be your problem, unless a blk_t is > essentially an alias for block_order_log_t. > > Hope this helps! > > --- > Tony Wetmore > Raytheon Solipsys > mailto:tony.wetmore@xxxxxxxxxxxx > http://www.solipsys.com > > > > > -----Original Message----- > From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On > Behalf Of Joseph D. Wagner > Sent: Tuesday, October 14, 2003 9:54 PM > To: gcc-help@xxxxxxxxxxx > Subject: Trouble with realloc > > > I know this is a stupid, simple problem, and the answer is staring me > right > in the face, but I can't see it. I know you're going to laugh at me the > > moment you're done reading this email, but please help me just the same. > > I keep getting a segmentation fault on realloc. > > I've tried every combination of * and & that I can think of, but nothing > > helps. > > struct block_order_log_t > { > e2_blkcnt_t totalBlocks; > blk_t *blockID; > }; > > ... > > struct ext2_inode inode; > struct block_order_log_t block_order_log; > > ... > > block_order_log.blockID = (blk_t*) calloc(inode.i_blocks, > sizeof(struct block_order_log_t)); > > ... > > /* Allocates more memory for the log if needed */ if(inode.i_blocks > > block_order_log.totalBlocks) { > /* The problem is here */ > block_order_log.blockID = (blk_t*) realloc(block_order_log.blockID, > sizeof(struct block_order_log_t) * inode.i_blocks); > } > > TIA. > > Joseph D. Wagner > > --------------------------------------------------------------------- > > "Introducing Microsoft Windows 2003 Server. Do more with less." > -- MS Sales Motto > > "Do more with less"? Are you saying Windows 2003 is less?