question about realloc

This is a discussion on question about realloc within the C Programming forums, part of the General Programming Boards category; I was wondering about how realloc is implemented: so lets say you originally had an n-byte array malloc'ed and you ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    question about realloc

    I was wondering about how realloc is implemented: so lets say you originally had an n-byte array malloc'ed and you want to now have a 2n-byte array. Then realloc can increase the bytes available for use right?

    And if there's no immediate space near your original memory block then realloc will move the original n-byte array to a new location to make room for the 2n-byte, right?

    But then in doing that move does realloc free the location originally used for the n-byte array?

    Thanks!

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    Quote Originally Posted by donthate View Post
    But then in doing that move does realloc free the location originally used for the n-byte array?
    Yes.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    13
    Great, thank you!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Realloc Quick Question.
    By killpoppop in forum C Programming
    Replies: 36
    Last Post: 01-13-2009, 12:04 PM
  3. Quick realloc question
    By Matt13 in forum C Programming
    Replies: 7
    Last Post: 04-02-2004, 07:40 AM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21