Changeset 215c1a851ceb2a32c721381954ffa0b68c547432

Show
Ignore:
Timestamp:
14/12/02 20:34:07 (6 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1039894447 +0000
git-parent:

[c4fde1e51a66497c0019872f19b786a7554dae5f]

git-author:
Gildas Bazin <gbazin@videolan.org> 1039894447 +0000
Message:

* src/misc/objects.c: implemented the FIND_CHILD mode for vlc_list_find().

vlc_object_get() now increments the refcount of the object so you'll need to release

the object at some point.
* src/misc/variables.c, ALL: var_Change() with VLC_VAR_GETLIST now returns a vlc_value_t
which points to a vlc_list_t.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/variables.h

    ra71b1c8 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.h,v 1.10 2002/12/13 01:56:29 gbazin Exp $ 
     5 * $Id: variables.h,v 1.11 2002/12/14 19:34:07 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    5252    /* If the variable is to be chosen in a list */ 
    5353    int          i_default; 
    54     int          i_choices; 
    55     vlc_value_t *pp_choices; 
     54    vlc_list_t   choices; 
    5655 
    5756    /* Set to TRUE if the variable is in a callback */ 
  • include/vlc/vlc.h

    ra71b1c8 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998, 1999, 2000 VideoLAN 
    5  * $Id: vlc.h,v 1.19 2002/12/13 01:56:29 gbazin Exp $ 
     5 * $Id: vlc.h,v 1.20 2002/12/14 19:34:07 gbazin Exp $ 
    66 * 
    77 * This program is free software; you can redistribute it and/or modify 
     
    4242    void *          p_address; 
    4343    vlc_object_t *  p_object; 
     44    vlc_list_t *    p_list; 
    4445 
    4546    /* Make sure the structure is at least 64bits */ 
  • modules/control/rc/rc.c

    rec51872 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: rc.c,v 1.16 2002/12/07 23:50:30 massiot Exp $ 
     5 * $Id: rc.c,v 1.17 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Peter Surda <shurdeek@panorama.sth.ac.at> 
     
    736736        /* Retrieve all registered ***. */ 
    737737        vlc_value_t val; 
    738         int i, i_vals; 
    739         vlc_value_t * p_vals; 
    740         const char * psz_value; 
     738        int i; 
     739        char * psz_value; 
    741740 
    742741        if ( var_Get( (vlc_object_t *)p_aout, psz_variable, &val ) < 0 ) 
     
    756755 
    757756        printf( "+----[ %s ]\n", psz_name ); 
    758         i_vals = ((vlc_value_t *)val.p_address)[0].i_int; 
    759         p_vals = &((vlc_value_t *)val.p_address)[1]; /* Starts at index 1 */ 
    760         for ( i = 0; i < i_vals; i++ ) 
    761         { 
    762             if ( !strcmp( psz_value, p_vals[i].psz_string ) ) 
    763                 printf( "| %s *\n", p_vals[i].psz_string ); 
     757        for ( i = 0; i < val.p_list->i_count; i++ ) 
     758        { 
     759            if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) 
     760                printf( "| %s *\n", val.p_list->p_values[i].psz_string ); 
    764761            else 
    765                 printf( "| %s\n", p_vals[i].psz_string ); 
     762                printf( "| %s\n", val.p_list->p_values[i].psz_string ); 
    766763        } 
    767764        var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_FREELIST, 
  • modules/gui/macosx/intf.m

    r2397666 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: intf.m,v 1.9 2002/12/08 23:38:02 massiot Exp $ 
     5 * $Id: intf.m,v 1.10 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> 
     
    840840    NSMenu * o_menu = [o_mi submenu]; 
    841841    vlc_value_t val; 
    842     int i_vals; 
    843     vlc_value_t * p_vals; 
    844842    char * psz_value; 
    845843 
     
    864862    } 
    865863 
    866     i_vals = ((vlc_value_t *)val.p_address)[0].i_int; 
    867     p_vals = &((vlc_value_t *)val.p_address)[1]; /* Starts at index 1 */ 
    868  
    869864    /* make (un)sensitive */ 
    870     [o_mi setEnabled: (i_vals > 0)]; 
    871  
    872     for ( i = 0; i < i_vals; i++ ) 
     865    [o_mi setEnabled: (val.p_list->i_count > 0)]; 
     866 
     867    for ( i = 0; i < val.p_list->i_count; i++ ) 
    873868    { 
    874869        NSMenuItem * o_lmi; 
    875870        NSString * o_title; 
    876871 
    877         o_title = [NSString stringWithCString: p_vals[i].psz_string]; 
     872        o_title = [NSString stringWithCString: val.p_list->p_values[i].psz_string]; 
    878873        o_lmi = [o_menu addItemWithTitle: o_title 
    879874                 action: pf_callback keyEquivalent: @""]; 
     
    884879        [o_lmi setTarget: o_controls]; 
    885880 
    886         if ( !strcmp( psz_value, p_vals[i].psz_string ) ) 
     881        if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) 
    887882            [o_lmi setState: NSOnState]; 
    888883    } 
  • modules/misc/testsuite/test4.c

    r0d62cd7 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: test4.c,v 1.5 2002/12/07 15:25:26 gbazin Exp $ 
     5 * $Id: test4.c,v 1.6 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    8383{ 
    8484    vlc_value_t val; 
    85     int i, i_vals; 
    86     vlc_value_t *p_vals; 
     85    int i; 
    8786 
    8887    var_Create( p_this, "honk", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); 
     
    114113 
    115114    var_Change( p_this, "honk", VLC_VAR_GETLIST, &val ); 
    116     i_vals = ((vlc_value_t*)val.p_address)[0].i_int; 
    117     p_vals = &((vlc_value_t*)val.p_address)[1]; 
    118     for( i = 0 ; i < i_vals ; i++ ) 
    119     { 
    120         printf( "value %i: %s\n", i, p_vals[i].psz_string ); 
     115    for( i = 0 ; i < val.p_list->i_count ; i++ ) 
     116    { 
     117        printf( "value %i: %s\n", i, val.p_list->p_values[i].psz_string ); 
    121118    } 
    122119    var_Change( p_this, "honk", VLC_VAR_FREELIST, &val ); 
     
    308305        int id = (int) (MAXOBJ * i_level * 1.0 * rand() / (RAND_MAX)); 
    309306        vlc_object_get( p_this, pp_objects[id]->i_object_id ); 
     307        vlc_object_release( p_this ); 
    310308    } 
    311309 
  • src/libvlc.c

    ra71b1c8 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2002 VideoLAN 
    5  * $Id: libvlc.c,v 1.51 2002/12/13 01:56:30 gbazin Exp $ 
     5 * $Id: libvlc.c,v 1.52 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    256256    { 
    257257        //module_EndBank( p_vlc ); 
     258        if( i_object ) vlc_object_release( p_vlc ); 
    258259        return VLC_EGENERIC; 
    259260    } 
     
    269270        vlc_object_destroy( p_help_module ); 
    270271        //module_EndBank( p_vlc ); 
     272        if( i_object ) vlc_object_release( p_vlc ); 
    271273        return VLC_EGENERIC; 
    272274    } 
     
    299301        vlc_object_destroy( p_help_module ); 
    300302        //module_EndBank( p_vlc ); 
     303        if( i_object ) vlc_object_release( p_vlc ); 
    301304        return VLC_EEXIT; 
    302305    } 
     
    346349    { 
    347350        //module_EndBank( p_vlc ); 
     351        if( i_object ) vlc_object_release( p_vlc ); 
    348352        return VLC_EEXIT; 
    349353    } 
     
    368372#endif 
    369373        //module_EndBank( p_vlc ); 
     374        if( i_object ) vlc_object_release( p_vlc ); 
    370375        return VLC_EGENERIC; 
    371376    } 
     
    463468    } 
    464469 
     470    msg_Err( p_vlc, "SIZEOF: %i", sizeof(vlc_list_t) ); 
     471    msg_Err( p_vlc, "SIZEOF: %i", sizeof(vlc_value_t) ); 
     472 
    465473    /* 
    466474     * Initialize playlist and get commandline files 
     
    475483        } 
    476484        //module_EndBank( p_vlc ); 
     485        if( i_object ) vlc_object_release( p_vlc ); 
    477486        return VLC_EGENERIC; 
    478487    } 
     
    483492    GetFilenames( p_vlc, i_argc, ppsz_argv ); 
    484493 
     494    if( i_object ) vlc_object_release( p_vlc ); 
    485495    return VLC_SUCCESS; 
    486496} 
     
    529539    { 
    530540        msg_Err( p_vlc, "interface initialization failed" ); 
     541        if( i_object ) vlc_object_release( p_vlc ); 
    531542        return VLC_EGENERIC; 
    532543    } 
     
    539550        vlc_object_detach( p_intf ); 
    540551        intf_Destroy( p_intf ); 
     552        if( i_object ) vlc_object_release( p_vlc ); 
    541553        return i_err; 
    542554    } 
    543555 
     556    if( i_object ) vlc_object_release( p_vlc ); 
    544557    return VLC_SUCCESS; 
    545558} 
     
    605618    vlc_threads_end( &libvlc ); 
    606619 
     620    if( i_object ) vlc_object_release( p_vlc ); 
    607621    return VLC_SUCCESS; 
    608622} 
     
    627641    p_vlc->b_die = VLC_TRUE; 
    628642 
     643    if( i_object ) vlc_object_release( p_vlc ); 
    629644    return VLC_SUCCESS; 
    630645} 
     
    658673        if( p_playlist == NULL ) 
    659674        { 
     675            if( i_object ) vlc_object_release( p_vlc ); 
    660676            return VLC_EGENERIC; 
    661677        } 
     
    668684    vlc_object_release( p_playlist ); 
    669685 
     686    if( i_object ) vlc_object_release( p_vlc ); 
    670687    return i_err; 
    671688} 
     
    679696{ 
    680697    vlc_t *p_vlc; 
     698    int i_ret; 
    681699 
    682700    p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 
     
    713731                    break; 
    714732            } 
     733            if( i_object ) vlc_object_release( p_vlc ); 
    715734            return VLC_SUCCESS; 
    716735        } 
    717736    } 
    718737 
    719     return var_Set( p_vlc, psz_var, value ); 
     738    i_ret = var_Set( p_vlc, psz_var, value ); 
     739 
     740    if( i_object ) vlc_object_release( p_vlc ); 
     741    return i_ret; 
    720742} 
    721743 
     
    728750{ 
    729751    vlc_t *p_vlc; 
     752    int i_ret; 
    730753 
    731754    p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 
     
    736759    } 
    737760 
    738     return var_Get( p_vlc, psz_var, p_value ); 
     761    i_ret = var_Get( p_vlc, psz_var, p_value ); 
     762 
     763    if( i_object ) vlc_object_release( p_vlc ); 
     764    return i_ret; 
    739765} 
    740766 
     
    770796    if( !p_playlist ) 
    771797    { 
     798        if( i_object ) vlc_object_release( p_vlc ); 
    772799        return VLC_ENOOBJ; 
    773800    } 
     
    786813    vlc_object_release( p_playlist ); 
    787814 
     815    if( i_object ) vlc_object_release( p_vlc ); 
    788816    return VLC_SUCCESS; 
    789817} 
     
    854882    } 
    855883 
     884    if( i_object ) vlc_object_release( p_vlc ); 
    856885    return VLC_SUCCESS; 
    857886} 
     
    876905    if( !p_input ) 
    877906    { 
     907        if( i_object ) vlc_object_release( p_vlc ); 
    878908        return VLC_ENOOBJ; 
    879909    } 
     
    882912    vlc_object_release( p_input ); 
    883913 
     914    if( i_object ) vlc_object_release( p_vlc ); 
    884915    return VLC_SUCCESS; 
    885916} 
     
    904935    if( !p_vout ) 
    905936    { 
     937        if( i_object ) vlc_object_release( p_vlc ); 
    906938        return VLC_ENOOBJ; 
    907939    } 
     
    910942    vlc_object_release( p_vout ); 
    911943 
     944    if( i_object ) vlc_object_release( p_vlc ); 
    912945    return VLC_SUCCESS; 
    913946} 
  • src/misc/objects.c

    ra71b1c8 r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: objects.c,v 1.32 2002/12/13 01:56:30 gbazin Exp $ 
     5 * $Id: objects.c,v 1.33 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    6161static void           ListReplace   ( vlc_list_t *, vlc_object_t *, int ); 
    6262static void           ListAppend    ( vlc_list_t *, vlc_object_t * ); 
     63static int            CountChildren ( vlc_object_t *, int ); 
     64static void           ListChildren  ( vlc_list_t *, vlc_object_t *, int ); 
    6365 
    6466/***************************************************************************** 
     
    352354                { 
    353355                    vlc_mutex_unlock( &structure_lock ); 
     356                    pp_objects[i_middle+1]->i_refcount++; 
    354357                    return pp_objects[i_middle+1]; 
    355358                } 
     
    360363        { 
    361364            vlc_mutex_unlock( &structure_lock ); 
     365            pp_objects[i_middle]->i_refcount++; 
    362366            return pp_objects[i_middle]; 
    363367        } 
     
    491495{ 
    492496    vlc_list_t list; 
     497    vlc_object_t **pp_current, **pp_end; 
     498    int i_count = 0, i_index = 0; 
    493499 
    494500    vlc_mutex_lock( &structure_lock ); 
    495501 
    496502    /* Look for the objects */ 
    497     if( (i_mode & 0x000f) == FIND_ANYWHERE ) 
    498     { 
    499         vlc_object_t **pp_current, **pp_end; 
    500         int i_count = 0, i_index = 0; 
    501  
     503    switch( i_mode & 0x000f ) 
     504    { 
     505    case FIND_ANYWHERE: 
    502506        pp_current = p_this->p_libvlc->pp_objects; 
    503507        pp_end = pp_current + p_this->p_libvlc->i_objects; 
     
    524528            } 
    525529        } 
    526     } 
    527     else 
    528     { 
     530    break; 
     531 
     532    case FIND_CHILD: 
     533        i_count = CountChildren( p_this, i_type ); 
     534        list = NewList( i_count ); 
     535 
     536        /* Check allocation was successful */ 
     537        if( list.i_count != i_count ) 
     538        { 
     539            msg_Err( p_this, "list allocation failed!" ); 
     540            list.i_count = 0; 
     541            break; 
     542        } 
     543 
     544        list.i_count = 0; 
     545        ListChildren( &list, p_this, i_type ); 
     546        break; 
     547 
     548    default: 
    529549        msg_Err( p_this, "unimplemented!" ); 
    530550        list = NewList( 0 ); 
     551        break; 
    531552    } 
    532553 
     
    571592 
    572593        vlc_mutex_unlock( &structure_lock ); 
     594 
     595        if( *newval.psz_string ) 
     596        { 
     597            vlc_object_release( p_this ); 
     598    } 
    573599    } 
    574600    else if( *psz_cmd == 'l' ) 
     
    916942    return; 
    917943} 
     944 
     945static int CountChildren( vlc_object_t *p_this, int i_type ) 
     946{ 
     947    vlc_object_t *p_tmp; 
     948    int i, i_count = 0; 
     949 
     950    for( i = 0; i < p_this->i_children; i++ ) 
     951    { 
     952        p_tmp = p_this->pp_children[i]; 
     953 
     954        if( p_tmp->i_object_type == i_type ) 
     955        { 
     956            i_count++; 
     957        } 
     958 
     959        if( p_tmp->i_children ) 
     960        { 
     961            i_count += CountChildren( p_tmp, i_type ); 
     962        } 
     963    } 
     964 
     965    return i_count; 
     966} 
     967 
     968static void ListChildren( vlc_list_t *p_list, vlc_object_t *p_this, int i_type ) 
     969{ 
     970    vlc_object_t *p_tmp; 
     971    int i; 
     972 
     973    for( i = 0; i < p_this->i_children; i++ ) 
     974    { 
     975        p_tmp = p_this->pp_children[i]; 
     976 
     977        if( p_tmp->i_object_type == i_type ) 
     978        { 
     979            ListReplace( p_list, p_tmp, p_list->i_count++ ); 
     980        } 
     981 
     982        if( p_tmp->i_children ) 
     983        { 
     984            ListChildren( p_list, p_tmp, i_type ); 
     985        } 
     986    } 
     987} 
  • src/misc/variables.c

    r05b378d r215c1a8  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.c,v 1.17 2002/12/10 18:22:01 gbazin Exp $ 
     5 * $Id: variables.c,v 1.18 2002/12/14 19:34:06 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    133133 
    134134    p_var->i_default = -1; 
    135     p_var->i_choices = 0; 
    136     p_var->pp_choices = NULL; 
     135    p_var->choices.i_count = 0; 
     136    p_var->choices.p_values = NULL; 
    137137 
    138138    p_var->b_incallback = VLC_FALSE; 
     
    221221 
    222222    /* Free choice list if needed */ 
    223     if( p_var->pp_choices
    224     { 
    225         for( i = 0 ; i < p_var->i_choices ; i++ ) 
    226         { 
    227             p_var->pf_free( &p_var->pp_choices[i] ); 
    228         } 
    229         free( p_var->pp_choices ); 
     223    if( p_var->choices.i_count
     224    { 
     225        for( i = 0 ; i < p_var->choices.i_count ; i++ ) 
     226        { 
     227            p_var->pf_free( &p_var->choices.p_values[i] ); 
     228        } 
     229        free( p_var->choices.p_values ); 
    230230    } 
    231231 
     
    310310            CheckValue( p_var, &p_var->val ); 
    311311            break; 
    312  
    313312        case VLC_VAR_ADDCHOICE: 
    314313            /* FIXME: the list is sorted, dude. Use something cleverer. */ 
    315             for( i = p_var->i_choices ; i-- ; ) 
    316             { 
    317                 if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) < 0 ) 
     314            for( i = p_var->choices.i_count ; i-- ; ) 
     315            { 
     316                if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) < 0 ) 
    318317                { 
    319318                    break; 
     
    329328            } 
    330329 
    331             INSERT_ELEM( p_var->pp_choices, p_var->i_choices, i, *p_val ); 
    332             p_var->pf_dup( &p_var->pp_choices[i] ); 
     330            INSERT_ELEM( p_var->choices.p_values, p_var->choices.i_count, 
     331                         i, *p_val ); 
     332            p_var->pf_dup( &p_var->choices.p_values[i] ); 
    333333 
    334334            CheckValue( p_var, &p_var->val ); 
     
    336336        case VLC_VAR_DELCHOICE: 
    337337            /* FIXME: the list is sorted, dude. Use something cleverer. */ 
    338             for( i = 0 ; i < p_var->i_choices ; i++ ) 
    339             { 
    340                 if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) == 0 ) 
     338            for( i = 0 ; i < p_var->choices.i_count ; i++ ) 
     339            { 
     340                if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 ) 
    341341                { 
    342342                    break; 
     
    344344            } 
    345345 
    346             if( i == p_var->i_choices
     346            if( i == p_var->choices.i_count
    347347            { 
    348348                /* Not found */ 
     
    360360            } 
    361361 
    362             p_var->pf_free( &p_var->pp_choices[i] ); 
    363             REMOVE_ELEM( p_var->pp_choices, p_var->i_choices, i ); 
     362            p_var->pf_free( &p_var->choices.p_values[i] ); 
     363            REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i ); 
    364364 
    365365            CheckValue( p_var, &p_var->val ); 
     
    367367        case VLC_VAR_SETDEFAULT: 
    368368            /* FIXME: the list is sorted, dude. Use something cleverer. */ 
    369             for( i = 0 ; i < p_var->i_choices ; i++ ) 
    370             { 
    371                 if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) == 0 ) 
     369            for( i = 0 ; i < p_var->choices.i_count ; i++ ) 
     370            { 
     371                if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 ) 
    372372                { 
    373373                    break; 
     
    375375            } 
    376376 
    377             if( i == p_var->i_choices
     377            if( i == p_var->choices.i_count
    378378            { 
    379379                /* Not found */ 
     
    386386 
    387387        case VLC_VAR_GETLIST: 
    388             p_val->p_address = malloc( (1 + p_var->i_choices) 
    389                                         * sizeof(vlc_value_t) ); 
    390             ((vlc_value_t*)p_val->p_address)[0].i_int = p_var->i_choices; 
    391             for( i = 0 ; i < p_var->i_choices ; i++ ) 
    392             { 
    393                 ((vlc_value_t*)p_val->p_address)[i+1] = p_var->pp_choices[i]; 
    394                 p_var->pf_dup( &((vlc_value_t*)p_val->p_address)[i+1] ); 
     388            p_val->p_list = malloc( sizeof(vlc_list_t) ); 
     389            p_val->p_list->p_values = malloc( p_var->choices.i_count 
     390                                              * sizeof(vlc_value_t) ); 
     391            p_val->p_list->i_count = p_var->choices.i_count; 
     392            for( i = 0 ; i < p_var->choices.i_count ; i++ ) 
     393            { 
     394                p_val->p_list->p_values[i] = p_var->choices.p_values[i]; 
     395                p_var->pf_dup( &p_val->p_list->p_values[i] ); 
    395396            } 
    396397            break; 
    397398        case VLC_VAR_FREELIST: 
    398             for( i = ((vlc_value_t*)p_val->p_address)[0].i_int ; i-- ; ) 
    399             { 
    400                 p_var->pf_free( &((vlc_value_t*)p_val->p_address)[i+1] ); 
    401             } 
    402             free( p_val->p_address ); 
     399            for( i = p_val->p_list->i_count ; i-- ; ) 
     400            { 
     401                p_var->pf_free( &p_val->p_list->p_values[i] ); 
     402            } 
     403            free( p_val->p_list->p_values ); 
     404        free( p_val->p_list ); 
    403405            break; 
    404406 
     
    837839{ 
    838840    /* Check that our variable is in the list */ 
    839     if( p_var->i_type & VLC_VAR_HASCHOICE && p_var->i_choices
     841    if( p_var->i_type & VLC_VAR_HASCHOICE && p_var->choices.i_count
    840842    { 
    841843        int i; 
    842844 
    843845        /* FIXME: the list is sorted, dude. Use something cleverer. */ 
    844         for( i = p_var->i_choices ; i-- ; ) 
    845         { 
    846             if( p_var->pf_cmp( *p_val, p_var->pp_choices[i] ) == 0 ) 
     846        for( i = p_var->choices.i_count ; i-- ; ) 
     847        { 
     848            if( p_var->pf_cmp( *p_val, p_var->choices.p_values[i] ) == 0 ) 
    847849            { 
    848850                break; 
     
    855857            /* Free the old variable, get the new one, dup it */ 
    856858            p_var->pf_free( p_val ); 
    857             *p_val = p_var->pp_choices[p_var->i_default >= 0 
    858                                         ? p_var->i_default : 0 ]; 
     859            *p_val = p_var->choices.p_values[p_var->i_default >= 0 
     860                                          ? p_var->i_default : 0 ]; 
    859861            p_var->pf_dup( p_val ); 
    860862        } 
     
    908910    } 
    909911} 
    910