add strings to console variables
[vg.git] / vg_settings_menu.h
index 68b2171a5c6f2b995a90f84afcc8911ae2429c4c..fb6a11616c3d688f642fdc16f18819fe1f4f9389 100644 (file)
@@ -261,10 +261,7 @@ static void vg_settings_audio_apply(void){
          SDL_CloseAudioDevice( vg_audio.sdl_output_device );
       }
       
-      if( vg_audio.force_device_name ){
-         free( vg_audio.force_device_name );
-         vg_audio.force_device_name = NULL;
-      }
+      vg_strfree( &vg_audio.device_choice );
 
       if( vg_settings.audio_devices.new_value == -1 ){ }
       else if( vg_settings.audio_devices.new_value == -2 ){
@@ -282,9 +279,8 @@ static void vg_settings_audio_apply(void){
             }
          }
 
-         int len = strlen(oi->alias);
-         vg_audio.force_device_name = malloc(len+1);
-         memcpy( vg_audio.force_device_name, (void *)oi->alias, len+1 );
+         vg_strnull( &vg_audio.device_choice, NULL, -1 );
+         vg_strcat( &vg_audio.device_choice, oi->alias );
       }
 
       vg_audio_device_init();
@@ -339,12 +335,12 @@ static void vg_settings_open(void){
       oi->value = i;
    }
 
-   if( vg_audio.force_device_name ){
+   if( vg_audio.device_choice.buffer ){
       vg_settings.temp_audio_choice = -2;
 
       for( int i=0; i<count; i ++ ){
          struct ui_enum_opt *oi = &options[i+1];
-         if( !strcmp( oi->alias, vg_audio.force_device_name ) ){
+         if( !strcmp( oi->alias, vg_audio.device_choice.buffer ) ){
             vg_settings.temp_audio_choice = oi->value;
             break;
          }