Author: greatlrd
Date: Sat Jun 3 17:22:11 2006
New Revision: 22195
URL:
http://svn.reactos.ru/svn/reactos?rev=22195&view=rev
Log:
make malloc, calloc and some other function return NULL if size is 0
Modified:
trunk/reactos/lib/crt/stdlib/malloc.c
Modified: trunk/reactos/lib/crt/stdlib/malloc.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/stdlib/malloc.c?rev…
==============================================================================
--- trunk/reactos/lib/crt/stdlib/malloc.c (original)
+++ trunk/reactos/lib/crt/stdlib/malloc.c Sat Jun 3 17:22:11 2006
@@ -36,6 +36,9 @@
*/
void* malloc(size_t _size)
{
+ if ( _size == 0)
+ return NULL;
+
return HeapAlloc(hHeap, 0, ROUND_SIZE(_size));
}
@@ -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) );
}
@@ -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 @@
*/
void* _expand(void* _ptr, size_t _size)
{
+ if ( _size == 0)
+ return NULL;
+
return HeapReAlloc(hHeap, HEAP_REALLOC_IN_PLACE_ONLY, _ptr, ROUND_SIZE(_size));
}