ESP8266 Developer Zone The Official ESP8266 Forum 2016-01-21T17:09:21+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1642 2016-01-21T17:09:21+08:00 2016-01-21T17:09:21+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1642&p=5473#p5473 <![CDATA[Re: 现一个RTOS_SDK的BUG,当realloc的新大小为0时,并未释放原空间]]>
麻烦基于 ESP8266_RTOS_SDK_V1.3.0 更新附件 lib 测试。

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

感谢您对 ESP8266 的关注!
libfreertos_ESP8266_RTOS_SDK_V1.3.0.zip

Statistics: Posted by ESP_Faye — Thu Jan 21, 2016 5:09 pm


]]>
2016-01-19T14:43:10+08:00 2016-01-19T14:43:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1642&p=5429#p5429 <![CDATA[现一个RTOS_SDK的BUG,当realloc的新大小为0时,并未释放原空间]]>

Code:

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.

Statistics: Posted by tobewinner — Tue Jan 19, 2016 2:43 pm


]]>