Royce Mitchell III wrote:
@@ -60,6 +66,9
@@
*/
void* realloc(void* _ptr, size_t _size)
{
+ if ( _size == 0)
+ return NULL;
+
if (!_ptr) return malloc(_size);
if (_size) return HeapReAlloc(hHeap, 0, _ptr, ROUND_SIZE(_size));
free(_ptr);
@@ -71,6 +80,9 @@
*/
umm... shouldn't we call free() if we're going to return NULL because
size is 0?
realloc never frees the memory if it fails.
Also, the free() at the bottom is never called now.
it's wrong and shouldn't even be there ;)
void*
_expand(void* _ptr, size_t _size)
{
+ if ( _size == 0)
+ return NULL;
+
return HeapReAlloc(hHeap, HEAP_REALLOC_IN_PLACE_ONLY, _ptr, ROUND_SIZE(_size));
}
Again, shouldn't we free the existing buffer if we're returning NULL
because size is 0?
no, same as with realloc.
- Thomas