static void destroy_desktop_category( ASDesktopCategory **pdc ) { if( pdc ) { ASDesktopCategory *dc = *pdc ; if( dc ) { if( dc->name ) free( dc->name ); if( dc->index_name ) free( dc->index_name ); if( dc->entries ) { char **pe = PVECTOR_HEAD(char*,dc->entries); int i = PVECTOR_USED(dc->entries); while( --i >= 0 ) if( pe[i] ) free( pe[i] ); destroy_asvector( &(dc->entries) ); } LOCAL_DEBUG_OUT( "dc = %p, ref_count = %d", dc, dc->ref_count ) ; free( dc ); *pdc = NULL ; } }
void dirtree_add_category (dirtree_t *tree, ASCategoryTree *ct, ASDesktopCategory *dc, Bool include_children, ASHashTable *exclusions) { dirtree_t *t = NULL ; int i, valid_entries_num = 0 ; ASDesktopEntryInfo *entries ; ASSERT_TREE(tree); ASSERT_TREE(dc); ASSERT_TREE(ct); LOCAL_DEBUG_OUT( "DesktopCategory \"%s\", has %d entries", dc->name, PVECTOR_USED(dc->entries) ); entries = desktop_category_get_entries( ct, dc, include_children?1:0, exclusions, &valid_entries_num); if( entries ) { for( i = 0 ; i < valid_entries_num ; ++i ) { ASDesktopEntry *de = entries[i].de; ASDesktopCategory *sub_dc = entries[i].dc ; if( de->type != ASDE_TypeDirectory && include_children ) { if( desktop_entry_in_subcategory( ct, de, entries, valid_entries_num ) ) continue ; } t = dirtree_new (); if( dup_desktop_entry_Name( de, &(t->name) ) ) set_flags( t->flags, DIRTREE_NAME_IS_UTF8 ); if( dup_desktop_entry_Comment( de, &(t->Comment) ) ) set_flags( t->flags, DIRTREE_COMMENT_IS_UTF8 ); ref_desktop_entry( de ); t->de = de ; t->parent = tree; t->next = tree->child; tree->child = t; if( sub_dc ) { t->flags |= DIRTREE_DIR; dirtree_add_category (t, ct, sub_dc, include_children, exclusions); } } free( entries ) ; } }