--ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Updated patch: 1. Removed malloc/free calls for "struct anoninfo am_swap" entirely. It's a one time use structure just to grab long ints for swap stats. At most 24 bytes - hardly a contender for malloc here. On Tue, Oct 19, 2004 at 03:08:37PM -0700, Christopher Layne wrote: > Here is a patch to fix: > > 1. Change swap memory statistics reporting entirely from using SC_LIST > with swapctl() to SC_AINFO. This actually gives us accurate aggregate swap > information that matches with "swap -s". The older method did not. > > 2. _FILE_OFFSET_BITS=64 continually breaking builds on Solaris machines w/ > 32-bit arch's due to not allowing it under largefile compilation > environment (i.e. 32bit arch w/ 64-bit file support). > --ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="memory_solaris.cpp.patch" Index: kdebase/kcontrol/info/memory_solaris.cpp =================================================================== RCS file: /home/kde/kdebase/kcontrol/info/memory_solaris.cpp,v retrieving revision 1.3 diff -u -3 -p -r1.3 memory_solaris.cpp --- kdebase/kcontrol/info/memory_solaris.cpp 24 Feb 2004 11:30:07 -0000 1.3 +++ kdebase/kcontrol/info/memory_solaris.cpp 20 Oct 2004 07:46:59 -0000 @@ -7,8 +7,17 @@ #include #include #include + +/* Stop from crapping out on 32-bit architectures. */ + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 32 +#endif + #include #include +#include #define PAGETOK(a) (( (t_memsize) sysconf( _SC_PAGESIZE )) * (t_memsize) a) @@ -58,55 +67,27 @@ void KMemoryWidget::update() { /* * Swap Info */ - struct swaptable *swt; - struct swapent *ste; - int i; - int ndevs; + + struct anoninfo am_swap; long swaptotal; long swapfree; - char dummy[128]; + long swapused; - /* - * allocate memory to hold info for all swap devices - */ - if( (ndevs = swapctl( SC_GETNSWP, NULL )) < 1 ) - return; - if( (swt = (struct swaptable *) malloc( - sizeof( int ) - + ndevs * sizeof( struct swapent ))) == NULL ) { - return; - } + swaptotal = swapused = swapfree = 0L; /* - * fill in the required fields and retrieve the info thru swapctl() + * Retrieve overall swap information from anonymous memory structure - + * which is the same way "swap -s" retrieves it's statistics. + * + * swapctl(SC_LIST, void *arg) does not return what we are looking for. */ - swt->swt_n = ndevs; - ste = &(swt->swt_ent[0]); - for( i = 0; i < ndevs; i++ ) { - /* - * since we're not interested in the path(s), - * we'll re-use the same buffer - */ - ste->ste_path = dummy; - ste++; - } - swapctl( SC_LIST, swt ); - /* - * sum up the total/free pages - */ - swaptotal = swapfree = 0L; - ste = &(swt->swt_ent[0]); - for( i = 0; i < ndevs; i++ ) { - if( (! (ste->ste_flags & ST_INDEL)) - && (! (ste->ste_flags & ST_DOINGDEL)) ) { - swaptotal += ste->ste_pages; - swapfree += ste->ste_free; - } - ste++; - } - free( swt ); + if (swapctl(SC_AINFO, &am_swap) == -1) + return; + swaptotal = am_swap.ani_max; + swapused = am_swap.ani_resv; + swapfree = swaptotal - swapused; Memory_Info[SWAP_MEM] = PAGETOK(swaptotal); Memory_Info[FREESWAP_MEM] = PAGETOK(swapfree); --ikeVEW9yuYc//A+q Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________ This message is from the kde-solaris mailing list. Account management: https://mail.kde.org/mailman/listinfo/kde-solaris. Archives: http://lists.kde.org/. More info: http://www.kde.org/faq.html. --ikeVEW9yuYc//A+q--