[Python-bugs-list] [ python-Bugs-542181 ] Realloc behavior

noreply@sourceforge.net noreply@sourceforge.net
Wed, 10 Apr 2002 14:27:46 -0700


Bugs item #542181, was opened at 2002-04-10 17:18
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=542181&group_id=5470

Category: Python Interpreter Core
>Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Gustavo Niemeyer (niemeyer)
>Assigned to: Tim Peters (tim_one)
Summary: Realloc behavior

Initial Comment:
I was just looking in obmalloc.c, and found this code 
and comment: 
 
else if (narenas == maxarenas) { 
   /* Grow arenas.  Don't use realloc:  if this 
    * fails, we don't want to lose the base 
    * addresses we already have. 
[...] 
 
Realloc may be safely used here. Realloc's behavior 
on failure is usually misunderstood. It will return 
NULL, but *won't* touch the already allocated memory. 
 
I know there are other constraints in this piece of 
code, but at least this comment may be safely 
removed. 

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-04-10 17:27

Message:
Logged In: YES 
user_id=31435

I agree, at least about part of this, and will fix the 
comment (in fact we cannot use realloc here, but the stated 
reason for that is bogus).  The debug version of realloc is 
coded incorrectly for this case too, so it's not just a 
comment that's hosed here.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=542181&group_id=5470