greatlrd(a)svn.reactos.org wrote:
>@@ -52,6 +55,9 @@
> */
> void* calloc(size_t _nmemb, size_t _size)
> {
>+ if ( _size == 0)
>+ return NULL;
>+
> return HeapAlloc(hHeap, HEAP_ZERO_MEMORY, ROUND_SIZE(_nmemb*_size) );
> }
>
>
What if _nmemb is zero?
>
>@@ -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?
Also, the free() at the bottom is never called now.
> 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?