Replaced some large local variables by other means

This commit is contained in:
Thomas Schmitt 2011-05-08 17:47:43 +00:00
parent f5ceb22dea
commit 1b3558580e
8 changed files with 50 additions and 15 deletions

View File

@ -786,7 +786,7 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso,
struct stat stbuf;
struct SplitparT *split_parts= NULL;
int split_count= 0;
char part_path[SfileadrL], *part_name;
char *part_path= NULL, *part_name;
int partno, total_parts, new_total_parts;
off_t offset, bytes, total_bytes, disk_size, first_bytes;
@ -798,6 +798,8 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso,
ret= 3; goto ex;
}
Xorriso_alloc_meM(part_path, char, SfileadrL);
if((flag & 2) && !(compare_result & 2)) {
ret= Xorriso_mark_update_merge(xorriso, iso_rr_path, node,
!(compare_result & 1));
@ -1001,6 +1003,7 @@ overwrite:;
ex:;
if(split_parts!=NULL)
Splitparts_destroy(&split_parts, split_count, 0);
Xorriso_free_meM(part_path);
if(ret<=0)
return(ret);
if(deleted)

View File

@ -1080,13 +1080,15 @@ ex:;
int Xorriso_show_devices(struct XorrisO *xorriso, int flag)
{
char adr[BURN_DRIVE_ADR_LEN];
int i, j, max_dev_len= 1, pad;
char *adr= NULL;
int i, j, max_dev_len= 1, pad, ret;
struct burn_drive_info *drive_list= NULL;
unsigned int drive_count;
char *respt, perms[8];
struct stat stbuf;
Xorriso_alloc_meM(adr, char, BURN_DRIVE_ADR_LEN);
sprintf(xorriso->info_text, "Beginning to scan for devices ...\n");
Xorriso_info(xorriso,0);
@ -1103,7 +1105,7 @@ int Xorriso_show_devices(struct XorrisO *xorriso, int flag)
sprintf(xorriso->info_text, "No drives found");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
{ret= 0; goto ex;}
}
sprintf(xorriso->info_text, "Full drive scan done\n");
Xorriso_info(xorriso,0);
@ -1147,7 +1149,10 @@ int Xorriso_show_devices(struct XorrisO *xorriso, int flag)
burn_drive_info_free(drive_list);
Xorriso_process_msg_queues(xorriso,0);
return(1);
ret= 1;
ex:;
Xorriso_free_meM(adr);
return(ret);
}
@ -1580,13 +1585,16 @@ int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba,
struct burn_drive_info *dinfo= NULL;
struct burn_drive *drive= NULL;
off_t pos, data_count, to_read;
char data[64 * 1024], data_md5[16];
char *data= NULL, data_md5[16];
void *ctx = NULL;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to check session MD5 checksum", 0);
if(ret <= 0)
goto ex;
Xorriso_alloc_meM(data, char, 64 * 1024);
ret= iso_md5_start(&ctx);
if(ret <= 0) {
Xorriso_no_malloc_memory(xorriso, NULL, 0);
@ -1614,6 +1622,7 @@ ex:;
Xorriso_process_msg_queues(xorriso,0);
if(ctx != NULL)
iso_md5_end(&ctx, data_md5);
Xorriso_free_meM(data);
return(ret);
}

View File

@ -705,7 +705,7 @@ int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
unsigned int mbr_lba= 0;
off_t lb0_count;
char *respt, *path;
unsigned char lb0[2048];
unsigned char *lb0= NULL;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
IsoImage *image= NULL;
@ -714,6 +714,8 @@ int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
IsoBoot *bootcat_node;
Xorriso_alloc_meM(path, char, SfileadrL);
Xorriso_alloc_meM(lb0, unsigned char, 2048);
respt= xorriso->result_line;
if(xorriso->boot_count > 0) {
@ -837,6 +839,7 @@ ex:;
if(image != NULL)
iso_image_unref(image); /* release obtained reference */
Xorriso_free_meM(path);
Xorriso_free_meM(lb0);
return(ret);
}

View File

@ -1396,7 +1396,7 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
{
int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0;
int end_idx, old_idx, os_errno;
char quality_name[80], head_buffer[64*1024];
char quality_name[80], *head_buffer= NULL;
struct SpotlisT *spotlist= NULL;
struct CheckmediajoB *job= NULL;
struct FindjoB *findjob= NULL;
@ -1406,6 +1406,8 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
(*idx)= end_idx;
Xorriso_alloc_meM(head_buffer, char, 64 * 1024);
ret= Checkmediajob_new(&job, 0);
if(ret <= 0)
goto ex;
@ -1531,6 +1533,7 @@ ex:;
}
Spotlist_destroy(&spotlist, 0);
Checkmediajob_destroy(&job, 0);
Xorriso_free_meM(head_buffer);
return(ret);
}

View File

@ -146,7 +146,7 @@ int Xorriso__get_di(IsoNode *node, dev_t *dev, ino_t *ino, int flag)
{
int ret, i, i_end, imgid, error_code;
size_t value_length= 0;
char *value= NULL, msg[ISO_MSGS_MESSAGE_LEN], severity[80];
char *value= NULL, *msg= NULL, severity[80];
unsigned char *vpt;
static char *name= "isofs.di";
@ -155,13 +155,16 @@ int Xorriso__get_di(IsoNode *node, dev_t *dev, ino_t *ino, int flag)
Xorriso_get_di_counteR++;
#endif /* NIX */
msg= TSOB_FELD(char, ISO_MSGS_MESSAGE_LEN);
if(msg == NULL)
{ret= -1; goto ex;}
*dev= 0;
*ino= 0;
ret= iso_node_lookup_attr(node, name, &value_length, &value, 0);
if(ret <= 0) {
/* Drop any pending messages because there is no xorriso to take them */
iso_obtain_msgs("NEVER", &error_code, &imgid, msg, severity);
return(ret);
goto ex;
}
vpt= (unsigned char *) value;
for(i= 1; i <= vpt[0] && i < value_length; i++)
@ -170,7 +173,11 @@ int Xorriso__get_di(IsoNode *node, dev_t *dev, ino_t *ino, int flag)
for(i++; i < i_end && i < value_length; i++)
*ino= ((*ino) << 8) | vpt[i];
free(value);
return(1);
ret= 1;
ex:;
if(msg != NULL)
free(msg);
return(ret);
}

View File

@ -1111,13 +1111,14 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
int part_table_implicit= 0;
char *line, *sfe= NULL, mode[80], *form, *treatment;
char *in_pt, *out_pt, *nl_charset, *local_charset, *mode_pt;
char *dev_filter= NULL, xorriso_id[129];
char *dev_filter= NULL, *xorriso_id= NULL;
static char channel_prefixes[4][4]= {".","R","I","M"};
static char load_names[][20]= {"auto", "session", "track", "lba", "volid"};
static int max_load_mode= 4;
struct Xorriso_lsT *paths, *leafs, *s, *plst, *vlst;
Xorriso_alloc_meM(sfe, char, 5 * SfileadrL + 80);
Xorriso_alloc_meM(xorriso_id, char, 129);
no_defaults= flag&1;
line= xorriso->result_line;
@ -1974,6 +1975,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
ret= 1;
ex:;
Xorriso_free_meM(sfe);
Xorriso_free_meM(xorriso_id);
return(ret);
}

View File

@ -252,7 +252,7 @@ int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
int ret, options, system_area_options, iso_lba= -1, start_lba, image_blocks;
char volid[33];
FILE *fp= NULL;
char buf[32768], *bufpt= NULL;
char *buf= NULL, *bufpt= NULL;
off_t hd_lba;
unsigned char *ub;
ElToritoBootImage *bootimg;
@ -260,6 +260,7 @@ int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
uint32_t offst;
enum burn_disc_status state;
Xorriso_alloc_meM(buf, char, 32768);
system_area_options= xorriso->system_area_options;
memset(buf, 0, 32768);
if(xorriso->system_area_disk_path[0] == 0) {
@ -379,6 +380,7 @@ do_set:;
ex:;
if(fp != NULL && fp != stdin)
fclose(fp);
Xorriso_free_meM(buf);
return(ret);
}
@ -1896,7 +1898,7 @@ int Xorriso_relax_compliance(struct XorrisO *xorriso, char *mode,
char *npt, *cpt;
int l, was, value, ret;
struct isoburn_imgen_opts *opts= NULL;
char msg[160];
char *msg= NULL;
off_t limit;
was= xorriso->relax_compliance;
@ -2065,10 +2067,13 @@ int Xorriso_relax_compliance(struct XorrisO *xorriso, char *mode,
if(xorriso->file_size_limit < Xorriso_default_file_size_limiT)
xorriso->file_size_limit= Xorriso_default_file_size_limiT;
} else {
Xorriso_alloc_meM(msg, char, 160);
sprintf(msg,
"-compliance iso_9660_level=%d : Only 1, 2, or 3 are permissible",
value);
Xorriso_msgs_submit(xorriso, 0, msg, 0, "FAILURE", 0);
Xorriso_free_meM(msg);
msg= NULL;
xorriso->relax_compliance= was;
return(0);
}
@ -2103,6 +2108,9 @@ int Xorriso_relax_compliance(struct XorrisO *xorriso, char *mode,
}
}
return(1);
ex:;
Xorriso_free_meM(msg);
return(ret);
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.08.083929"
#define Xorriso_timestamP "2011.05.08.174805"