Replaced some large local variables by other means in xorriso/emulators.c

This commit is contained in:
Thomas Schmitt 2011-05-03 09:10:40 +00:00
parent 59e46ea5d9
commit 84589ab9b8
2 changed files with 41 additions and 24 deletions

View File

@ -89,7 +89,7 @@ int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0; int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0;
int do_multi= 0, do_msinfo= 0, do_grow= 0, do_isosize= 0, do_xa1= 0; int do_multi= 0, do_msinfo= 0, do_grow= 0, do_isosize= 0, do_xa1= 0;
double write_start_address= -1.0, tsize= -1.0; double write_start_address= -1.0, tsize= -1.0;
char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt; char *track_source= NULL, *dev_adr= NULL, *cpt;
char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80]; char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80];
char speed[80]; char speed[80];
@ -144,6 +144,9 @@ static char blank_help[][80]= {
"@End_of_helptexT@" "@End_of_helptexT@"
}; };
Xorriso_alloc_meM(track_source, char, SfileadrL);
Xorriso_alloc_meM(dev_adr, char, SfileadrL);
strcpy(mem_report_about_text, xorriso->report_about_text); strcpy(mem_report_about_text, xorriso->report_about_text);
mem_do_close= xorriso->do_close; mem_do_close= xorriso->do_close;
@ -155,14 +158,14 @@ static char blank_help[][80]= {
if(xorriso->in_drive_handle != NULL) { if(xorriso->in_drive_handle != NULL) {
ret= Xorriso_option_dev(xorriso, "", 1|32); /* give up indev */ ret= Xorriso_option_dev(xorriso, "", 1|32); /* give up indev */
if(ret!=1) if(ret!=1)
return(ret); goto ex;
} }
/* Assess plan, make settings */ /* Assess plan, make settings */
for(i= 0; i<argc; i++) { for(i= 0; i<argc; i++) {
sprintf(xorriso->info_text, "-as %s: %s", sprintf(xorriso->info_text, "-as %s: ", whom);
whom, Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
for(k=0;ignored_partial_options[k][0]!=0;k++) { for(k=0;ignored_partial_options[k][0]!=0;k++) {
@ -179,8 +182,8 @@ static char blank_help[][80]= {
goto no_volunteer; goto no_volunteer;
if(0) { if(0) {
no_volunteer:; no_volunteer:;
sprintf(xorriso->info_text, "-as %s: Ignored option %s", sprintf(xorriso->info_text, "-as %s: Ignored option ", whom);
whom, Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
continue; continue;
} }
@ -211,9 +214,9 @@ no_volunteer:;
} else if(strcmp(cpt,"as_needed")==0) { } else if(strcmp(cpt,"as_needed")==0) {
strcpy(blank_mode, "as_needed"); strcpy(blank_mode, "as_needed");
} else { } else {
sprintf(xorriso->info_text, sprintf(xorriso->info_text, "-as %s: blank=", whom);
"-as %s: blank=%s not supported. See blank=help .", Text_shellsafe(argv[i], xorriso->info_text, 1);
whom, Text_shellsafe(argv[i], sfe, 0)); strcat(xorriso->info_text, " not supported. See blank=help .");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
@ -340,17 +343,17 @@ no_volunteer:;
0, "FATAL", 0); 0, "FATAL", 0);
ret= 0; goto ex; ret= 0; goto ex;
} else if(argv[i][0]=='-' && argv[i][1]!=0) { } else if(argv[i][0]=='-' && argv[i][1]!=0) {
sprintf(xorriso->info_text, "-as %s: Unknown option %s", sprintf(xorriso->info_text, "-as %s: Unknown option ", whom);
whom, Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} else { } else {
if(track_source[0]) { if(track_source[0]) {
sprintf(xorriso->info_text, "-as %s: Surplus track source %s", sprintf(xorriso->info_text, "-as %s: Surplus track source ", whom);
whom, Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
sprintf(xorriso->info_text, "First and only track source is %s", sprintf(xorriso->info_text, "First and only track source is ");
Text_shellsafe(track_source, sfe, 0)); Text_shellsafe(track_source, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
@ -493,6 +496,8 @@ ex:;
} }
Xorriso_option_report_about(xorriso, mem_report_about_text, 0); Xorriso_option_report_about(xorriso, mem_report_about_text, 0);
xorriso->do_close= mem_do_close; xorriso->do_close= mem_do_close;
Xorriso_free_meM(dev_adr);
Xorriso_free_meM(track_source);
return(ret); return(ret);
} }
@ -635,7 +640,6 @@ int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom,
"" ""
}; };
int k; int k;
char sfe[5*SfileadrL];
for(k=0;ignored_arg0_options[k][0]!=0;k++) for(k=0;ignored_arg0_options[k][0]!=0;k++)
if(strcmp(argpt,ignored_arg0_options[k])==0) if(strcmp(argpt,ignored_arg0_options[k])==0)
@ -647,8 +651,8 @@ int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom,
} }
return(0); return(0);
no_volunteer:; no_volunteer:;
sprintf(xorriso->info_text, "-as %s: Ignored option %s", sprintf(xorriso->info_text, "-as %s: Ignored option ", whom);
whom, Text_shellsafe(argpt, sfe, 0)); Text_shellsafe(argpt, xorriso->info_text, 1);
if(!(flag & 1)) if(!(flag & 1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(1); return(1);
@ -925,9 +929,9 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1; int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1;
int *weight_list= NULL, weight_count= 0; int *weight_list= NULL, weight_count= 0;
int *delay_opt_list= NULL, delay_opt_count= 0; int *delay_opt_list= NULL, delay_opt_count= 0;
char sfe[5*SfileadrL], adr[SfileadrL+8], ra_text[80], pathspec[2*SfileadrL]; char *sfe= NULL, *adr= NULL, ra_text[80], *pathspec= NULL;
char *ept, *add_pt, eff_path[SfileadrL], indev[SfileadrL+8], msc[80], *cpt; char *ept, *add_pt, *eff_path= NULL, *indev= NULL, msc[80], *cpt;
char old_root[SfileadrL], *argpt, *hargv[1]; char *old_root= NULL, *argpt, *hargv[1];
char *boot_path, partno_text[8], *iso_rr_pt, *disk_pt, *rpt, *wpt; char *boot_path, partno_text[8], *iso_rr_pt, *disk_pt, *rpt, *wpt;
char *rm_merge_args[3]; char *rm_merge_args[3];
@ -936,18 +940,25 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
struct stat stbuf; struct stat stbuf;
Xorriso_alloc_meM(sfe, char, 5*SfileadrL);
Xorriso_alloc_meM(adr, char, SfileadrL+8);
Xorriso_alloc_meM(pathspec, char, 2*SfileadrL);
Xorriso_alloc_meM(eff_path, char, SfileadrL);
Xorriso_alloc_meM(indev, char, SfileadrL+8);
Xorriso_alloc_meM(old_root, char, SfileadrL);
strcpy(ra_text, xorriso->report_about_text); strcpy(ra_text, xorriso->report_about_text);
weight_list= TSOB_FELD(int, (argc / 3) + 1); weight_list= TSOB_FELD(int, (argc / 3) + 1);
if(weight_list == NULL) { if(weight_list == NULL) {
Xorriso_no_malloc_memory(xorriso, NULL, 0); Xorriso_no_malloc_memory(xorriso, NULL, 0);
return(-1); {ret= -1; goto ex;}
} }
delay_opt_list= TSOB_FELD(int, argc + 1); delay_opt_list= TSOB_FELD(int, argc + 1);
if(delay_opt_list == NULL) { if(delay_opt_list == NULL) {
cpt= (char *) weight_list; cpt= (char *) weight_list;
Xorriso_no_malloc_memory(xorriso, &cpt, 0); Xorriso_no_malloc_memory(xorriso, &cpt, 0);
return(-1); {ret= -1; goto ex;}
} }
if(xorriso->boot_image_cat_path[0]) if(xorriso->boot_image_cat_path[0])
@ -1936,6 +1947,12 @@ ex:;
free(weight_list); free(weight_list);
if(delay_opt_list != NULL) if(delay_opt_list != NULL)
free(delay_opt_list); free(delay_opt_list);
Xorriso_free_meM(sfe);
Xorriso_free_meM(adr);
Xorriso_free_meM(pathspec);
Xorriso_free_meM(eff_path);
Xorriso_free_meM(indev);
Xorriso_free_meM(old_root);
return(ret); return(ret);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.03.085459" #define Xorriso_timestamP "2011.05.03.091059"