Talk:c/memory/realloc

Behavior when {{c|1= new_size
0}} ==

Shouldn't the behavior when only apply when  (for both the 'until C23' and 'since C23' blocks)?

The article does state just before that "If is null, the behavior is the same as calling ." but it doesn't seem immediately clear to me that the two following blocks describe the behavior when. --Elarz (talk) 10:48, 22 March 2022 (PDT)


 * Once it is "the same as calling malloc", the description is done; the rest is for the remaining cases (where it's not the same as calling malloc). To be fair, the standard does have the word "Otherwise" between the two sentences, I suppose it won't hurt here either. --Cubbi (talk) 10:48, 22 March 2022 (PDT)


 * Thanks, I understand the logical progression of the description now(The standard would have been confusing too for me without 'Otherwise'(which could tell more about myself than the standard to be honest)). I was obviously willing to make the edit so thanks for doing it yourself so quickly. --Elarz (talk) 11:35, 22 March 2022 (PDT)

I don't know if it's worth mentioning, but in C90, when and, it does free the pointer.
 * indeed, "4.10.3.4 The realloc function" says "If size is zero and ptr is not a null pointer, the object it points to is freed." --Cubbi (talk) 16:28, 13 April 2023 (PDT)