[Top][All Lists]

[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


                 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



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


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) {
                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:


  Nachricht gesendet von/durch Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]