This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Trouble with realloc
- From: "Joseph D. Wagner" <theman at josephdwagner dot info>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 15 Oct 2003 07:54:19 +0600
- 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?