Trouble with realloc

Joseph D. Wagner theman@josephdwagner.info
Wed Oct 15 12:54:00 GMT 2003


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?



More information about the Gcc-help mailing list