[ros-diffs] [greatlrd] 22195: make malloc, calloc and some other function return NULL if size is 0

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sat Jun 3 15:22:12 CEST 2006


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=22195&r1=22194&r2=22195&view=diff
==============================================================================
--- 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));
 }
 




More information about the Ros-diffs mailing list