mallocfreespace.c
Kate Feng
feng1 at bnl.gov
Thu May 24 18:04:00 UTC 2007
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
More information about the users
mailing list