现一个RTOS_SDK的BUG,当realloc的新大小为0时,并未释放原空间

tobewinner
Posts: 45
Joined: Tue Jan 19, 2016 2:39 pm

现一个RTOS_SDK的BUG,当realloc的新大小为0时,并未释放原空间

Postby tobewinner » Tue Jan 19, 2016 2:43 pm

当前代码如下:

Code: Select all

void *pvPortRealloc(void *mem, size_t newsize)

{

     void *p;     

     p = pvPortMalloc(newsize);

     if (p) {

       /* zero the memory */

       if (mem != NULL) {

         memcpy(p, mem, newsize);

         vPortFree(mem);

       }

     }

     return p;     

}

而realloc的介绍是,当newsize为0时相当于free:
The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged in the range from the start of the region up to the
minimum of the old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. If ptr is NULL, then the call is equivalent to mal‐
loc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an
earlier call to malloc(), calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 现一个RTOS_SDK的BUG,当realloc的新大小为0时,并未释放原空间

Postby ESP_Faye » Thu Jan 21, 2016 5:09 pm

您好,

麻烦基于 ESP8266_RTOS_SDK_V1.3.0 更新附件 lib 测试。

如果您的问题仍未解决,欢迎再与我们联系。

感谢您对 ESP8266 的关注!
Attachments
libfreertos_ESP8266_RTOS_SDK_V1.3.0.zip
(21.16 KiB) Downloaded 592 times

Who is online

Users browsing this forum: No registered users and 18 guests