From: Nir P. <ni...@em...> - 2004-02-07 07:02:56
|
Hi y'all, Just a small comment - not really coLinux related, but it is a general fault-tolerance issue: When using function calls that can fail (assuming co_os_malloc(), like malloc(), can run out of memory), one should always handle the failures. Of course, just returning an error here would not be enough - the higher levels must handle it too. Before you shoot me, yes - I know such code appears in SO MANY places, and in so many projects, but that doesn't mean we want more... Some people tend to say - "So what? if malloc() fails, I don't care, because nothing can work after it. Just buy more memory". But fault-tolerance is important to software. Especially to OS kernels. Nir Ballard, Jonathan wrote: > Hello, > > A few suggestions that help portability: > > > int co_os_poll_chain_wait(co_os_poll_chain_t chain) > { > //-- HANDLE wevents[chain->count]; > ++ HANDLE *wevents ; > DWORD result; > co_os_poll_t poll; > int i; > > ++ wevents = co_os_malloc( sizeof(HANDLE) * chain->count ) ; > > i=0; > co_list_each_entry(poll, &chain->list, node) { > wevents[i] = poll->event; > i++; > } > > result = MsgWaitForMultipleObjects(chain->count, (void * const > *)&wevents, > FALSE, INFINITE, QS_ALLINPUT); > > ++ co_os_free( wevents ) ; > > if (result == WAIT_OBJECT_0 + chain->count) > return 0; > . > > . > > . > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > coLinux-devel mailing list > coL...@li... > https://lists.sourceforge.net/lists/listinfo/colinux-devel |