Results 1 to 2 of 2

Thread: realloc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: realloc

    Your error is here:
    Qt Code:
    1. realloc( Val_, sizeof(double) * MC.ValLength_ );
    To copy to clipboard, switch view to plain text mode 

    Realloc can move the memory block to a new mem location when extending, if there is not enough room at the current location. You missed the fact that the new address is returned by realloc. Therefore you should have:

    Qt Code:
    1. Val_ = (double *)realloc( Val_, sizeof(double) * MC.ValLength_ );
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to marcel for this useful post:

    mickey (4th May 2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.