Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:58:40+00:00 2026-05-26T17:58:40+00:00

Confusion 1 : The man realloc says that the object will be moved if

  • 0

Confusion 1:
The man realloc says that the object will be moved if it has to do a new allocation to resize the object to a new size. However when downsizing, there are many places which says it is possible to move data in memory to a new place(SO). This is creating confusions in my head. How do we find that downsizing will rsult in new allocation or not as it is not explicitly mentioned for downsizing case in the man pages and in gnu page.

Confusion 2:
Also when we do following:

void * ptr1 = malloc(SOMEBIGSIZE);
void * ptr2 = realloc(ptr1, SOMESMALLSIZE);

evaluating ptr1==ptr2 results true. Which means that the ptr2 points same ptr1. So, which of the 2.1 or 2.2 is true?
(2.1) that ptr1 was not downsized which can be bad if SOMEBIGSIZE>>>SOMESMALLSIZE and we do not get any advantage in terms of memory.
(2.2) if the ptr1 is shrinked, then what happens to the memory in address range ptr1+SOMESMALLSIZE to ptr1+SOMEHUGESIZE? is it freed or marked free?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:58:41+00:00Added an answer on May 26, 2026 at 5:58 pm

    The C standard talks out the behavior of realloc from perspective of user program. It does not define the implementation.

    Following are the relevant requirements(asked in your Q) imposed by the standard on Implementations.

    C99 Standard 7.20.3.4-1: The realloc function:

    The realloc function deallocates the old object pointed to by ptr and returns a
    pointer to a new object that has the size specified by size. The contents of the new
    object shall be the same as that of the old object prior to deallocation, up to the lesser of the new and old sizes. Any bytes in the new object beyond the size of the old object have indeterminate values.

    C99 Standard 7.20.3.4-4:

    The realloc function returns a pointer to the new object (which may have the same value as a pointer to the old object), or a null pointer if the new object could not be allocated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some confusion with the new keyword,things work fine when I am
I'm having a bit of confusion in attempting to retroactively create a new base
There has always been a confusion with preg_match in php. I have a string
Why are pointers such a leading factor of confusion for many new, and even
I'm facing confusion with how JSP include tag works. What's happening is that the
Because of the confusion between all the info that is out there about mvc
According to the man page, pthread_cond_broadcast wakes up all the threads that are waiting
my confusion related to this matter is that how we can use a previously
Let's take some regular house with a man, which has to go to the
I have a confusion with wait() method of thread class. It is known that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.