cws@gigo.uucp (Carl Schmidtmann) (05/01/91)
The following code will do the function of the XmListDeleteAllItems. It has been used with both Motif 1.0 and 1.1. Basically it gets the items from the widget, frees them, sets the itemlist inside the widget to NULL and the itemcount to 0. The code has not broken any apps and even very large lists disappear fast. So far no memory leaks have been noticed. One note of caution: Be sure that all items are deselected before calling the clear_list routine. This code was written by Douglas Young and came into my possession via Golden Hills Computer Training. Carl ________________________________________________________________________________ Carl Schmidtmann | Still searching for the ultimate gigo!cws@decwrl.dec.com | Pan Galactic Gargle Blaster. ...!decwrl!gigo!cws | Don't Panic . . . ...!claris!wattres!gigo!cws | . . . this reality is only a test. ============================================================================= #include <Xm/Xm.h> #include <Xm/List.h> void clear_list( list ) Widget list; { Arg wargs[5]; int n, i, itemCount; XmStringTable items; XmListDeselectAllItems( list ); n = 0; XtSetArg( wargs[n], XmNitemCount, &itemCount ); n++; XtSetArg( wargs[n], XmNitems, &items ); n++; XtGetValues( list, wargs, n ); free_stringTable( items, itemCount ); n = 0; XtSetArg( wargs[n], XmNitemCount, 0 ); n++; XtSetArg( wargs[n], XmNitems, NULL ); n++; XtSetValues( list, wargs, n ); } void free_stringTable( itemList, itemCount ) XmStringTable itemList; int itemCount; { int i; if( itemList != NULL ) { for( i = 0; i < itemCount; i++ ) XmStringFree( itemList[i] ); XtFree( itemList ); } } -- ________________________________________________________________________________ Carl Schmidtmann | Still searching for the ultimate gigo!cws@decwrl.dec.com | Pan Galactic Gargle Blaster. ...!decwrl!gigo!cws | Don't Panic . . .