[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #40535] realloc(xxx, 0) doesn't free
From: |
Thomas R. |
Subject: |
[avr-libc-dev] [bug #40535] realloc(xxx, 0) doesn't free |
Date: |
Sun, 10 Nov 2013 11:11:10 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Firefox/22.0 |
URL:
<http://savannah.nongnu.org/bugs/?40535>
Summary: realloc(xxx, 0) doesn't free
Project: AVR C Runtime Library
Submitted by: glglgl
Submitted on: So 10 Nov 2013 11:11:09 GMT
Category: Library
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Percent Complete: 0%
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 1.8.0
Fixed Release: None
_______________________________________________________
Details:
realloc(xxx, 0) is supposed to free the given memory block if xxx is not NULL,
If xxx is NULL, realloc() is supposed to work like malloc().
So I suggest to modify
http://svn.sv.gnu.org/viewvc/trunk/avr-libc/libc/stdlib/realloc.c?revision=2127&root=avr-libc&view=markup
in that way to add after
/* Trivial case, required by C standard. */
if (ptr == 0)
return malloc(len);
the lines
/* Another trivial case, required by C standard. */
if (len == 0) {
free(ptr);
return NULL;
}
because in this case
* realloc(NULL, 0) returns the same as malloc(0)
* realloc(anythingelse, 0) does free(anythingelse).
This behaviour is required by the standard.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?40535>
_______________________________________________
Nachricht gesendet von/durch Savannah
http://savannah.nongnu.org/
- [avr-libc-dev] [bug #40535] realloc(xxx, 0) doesn't free,
Thomas R. <=