Advertisement

05.16.2008 at 03:28AM PDT, ID: 23407819
[x]
Attachment Details

clarification for realloc

Asked by pothios in C Programming Language

Tags: c

hello. i have the following code.

if realloc acts as malloc, return value of r = new pointer to a memory location. ptr will be NULL.

if realloc changes the location of the memory for a existing allocated memory, r and ptr will have different values. p will not be NULL like the 1st situation.

if realloc does its job without any changes to the location of the memory, r and ptr will be the same.

am i correct? thanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
void* realloc(void *ptr, size_t size) {
    static void* (*func)();
    void *r;
    if(!func) {
        func = (void *(*)())dlsym(RTLD_NEXT, "realloc");
    }
    r = func(ptr, size);
    printf("realloc %p %d %p\n", r, size, ptr);
    return r;
}
 
Loading Advertisement...
 
[+][-]05.16.2008 at 03:34AM PDT, ID: 21581531

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 03:35AM PDT, ID: 21581539

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 03:36AM PDT, ID: 21581542

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 03:37AM PDT, ID: 21581549

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 03:46AM PDT, ID: 21581601

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Tags: c
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628