[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mallocfreespace.c



Is it better to return 0 instead of -1 if there is no free space in the
heap ?

--- mallocfreespace.c.orig Mon Nov 29 17:45:43 2004
+++ mallocfreespace.c Thu May 24 13:57:24 2007
@@ -40,5 +40,5 @@
   if ( !rtems_region_get_free_information( RTEMS_Malloc_Heap,
&heap_info ) ) {
     return (size_t) heap_info.Free.largest;
   }
-  return (size_t) -1;
+  return (size_t) 0;
 }

Returning -1 broke the following code in EPICS :

return (malloc_free_space() > 100000 + contiguousBlockSize);

Perhaps,
return ( ((int) malloc_free_space() )> 100000 + contiguousBlockSize);

would be fine, but I thought it's better to return 0 if there is no
free space in the heap.  What do you think ?

Kate