The purpose of the loop is because if sysctl fails to alloc enough space in the second call, proclength is set to the length of data returned, not to the length of the data that could/should have been returned, so we have to start over again by passing NULL to sysctl to determine how big proclength should have been and try again.
Tom On 12/2/09 4:03 PM, "Miguel de Icaza" <mig...@novell.com> wrote: > Hello, > >> The overall patch looks good, but some small changes must be done >> before the patch can be committed: > > In addition to these comments, I fail to see the point of the do/while > loop, it seems to not be used at all. Can you explain the reason for > it? I might be missing something important. > >> >> >> @@ -1489,8 +1489,73 @@ >> } >> #endif /* UNUSED_CODE */ >> >> +#ifdef PLATFORM_MACOSX >> +#include <sys/sysctl.h> >> +#include <sys/proc.h> >> + >> Move header declarations to the top of the file. It doesn't matter we have >> other >> place with this, let's not make it worse. >> >> >> + if (err == 0) { >> + result = g_malloc (proclength); >> + if (result == NULL) { >> + err = ENOMEM; >> + } >> + } >> No need to guard against allocation failure with g_malloc as glib asserts on >> failure. >> >> The same applies to the loop around allocation failure. >> >> >> + free (result); >> + result = NULL; >> + *needed = j * sizeof(guint32); >> You must use g_free paired with g_malloc. >> >> >> I believe the code in process_open_compare is not optimal for OSX as >> it wastes time following the >> >> linux path. Please rework it to be something saner: >> >> >> #if defined(PLATFORM_MACOSX) >> ... >> >> #elif defined (PLATFORM_SOLARIS) >> #else >> ... >> #endif >> >> >> >> >> Thanks for the patch, >> >> Rodrigo >> >> >> >> _______________________________________________ >> Mono-devel-list mailing list >> Mono-devel-list@lists.ximian.com >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list