public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph D. Wagner" <theman@josephdwagner.info>
To: gcc-help@gcc.gnu.org
Subject: Trouble with realloc
Date: Wed, 15 Oct 2003 12:54:00 -0000	[thread overview]
Message-ID: <200310150754.19930.theman@josephdwagner.info> (raw)

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?

             reply	other threads:[~2003-10-15 12:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-15 12:54 Joseph D. Wagner [this message]
     [not found] <001501c3931e$c41ad2a0$5b02000a@solipsys.com>
2003-10-15 17:28 ` Joseph D. Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200310150754.19930.theman@josephdwagner.info \
    --to=theman@josephdwagner.info \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).