Trouble with realloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux