Replaced some large local variables by other means which save stack space

This commit is contained in:
Thomas Schmitt 2011-05-02 12:19:18 +00:00
parent 4b86308829
commit 84d2a2ba9d
2 changed files with 58 additions and 29 deletions

View File

@ -300,7 +300,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
int ret, missing= 0, is_split= 0, i, was_error= 0, diff_count= 0;
int content_shortcut= 0, mask;
char *respt;
char a[5*SfileadrL], sfe[5*SfileadrL];
char *a= NULL;
char ttx1[40], ttx2[40];
char *a1_acl= NULL, *a2_acl= NULL, *d1_acl= NULL, *d2_acl= NULL;
char *attrlist1= NULL, *attrlist2= NULL;
@ -308,18 +308,26 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
int split_count= 0;
time_t stamp;
char part_path[SfileadrL], *part_name;
char *part_path= NULL, *part_name;
int partno, total_parts= 0;
off_t offset, bytes, total_bytes;
a= TSOB_FELD(char, 5*SfileadrL);
if(a == NULL)
{ret= -1; goto ex;}
part_path= TSOB_FELD(char, SfileadrL);
if(part_path == NULL)
{ret= -1; goto ex;}
*result= 0;
respt= xorriso->result_line;
if(!(xorriso->disk_excl_mode&8)) {
ret= Xorriso_path_is_excluded(xorriso, disk_adr, 2 | !!(flag&(1<<27)));
if(ret>0) {
sprintf(respt , "? %s (DISK) : exluded by %s\n",
Text_shellsafe(disk_adr, sfe, 0),
strcpy(respt, "? ");
Text_shellsafe(disk_adr, respt, 1);
sprintf(respt + strlen(respt), " (DISK) : exluded by %s\n",
(ret==1 ? "-not_paths" : "-not_leaf"));
if(! (flag & ((1 << 31) | (1 << 26))))
Xorriso_result(xorriso,0);
@ -333,8 +341,10 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
else
ret= lstat(disk_adr, &s1);
if(ret==-1) {
sprintf(respt , "? %s (DISK) : cannot lstat() : %s\n",
Text_shellsafe(disk_adr, sfe, 0), strerror(errno));
strcpy(respt, "? ");
Text_shellsafe(disk_adr, respt, 1);
sprintf(respt + strlen(respt),
" (DISK) : cannot lstat() : %s\n", strerror(errno));
if(! (flag & ((1 << 31) | (1 << 26))))
Xorriso_result(xorriso,0);
missing= 1;
@ -347,7 +357,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
strcpy(a, Ftypetxt(s1.st_mode, 1));
strcat(a, " ");
if(adr_common_tail[0])
strcat(a, Text_shellsafe(adr_common_tail, sfe, 0));
Text_shellsafe(adr_common_tail, a, 1);
else {
Text_shellsafe(disk_adr, a+strlen(a), 0);
strcat(a, " (DISK)");
@ -361,8 +371,9 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
ret= Xorriso_iso_lstat(xorriso, iso_adr, &s2, 0);
if(ret<0) {
sprintf(respt, "? %s (ISO) : cannot find this file in ISO image\n",
Text_shellsafe(iso_adr, sfe, 0));
strcpy(respt, "? ");
Text_shellsafe(iso_adr, respt, 1);
strcat(respt, " (ISO) : cannot find this file in ISO image\n");
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
missing= 1;
@ -652,6 +663,10 @@ ex:;
free(a2_acl);
if(d2_acl != NULL)
free(d2_acl);
if(part_path != NULL)
free(part_path);
if(a != NULL)
free(a);
return(ret);
}
@ -661,20 +676,28 @@ int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path,
char disk_path[SfileadrL], int flag)
{
int ret;
char adrc[SfileadrL];
char *adrc= NULL;
adrc= TSOB_FELD(char, SfileadrL);
if(adrc == NULL)
{ret= -1; goto ex;}
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
return(-1);
{ret= -1; goto ex;}
if(strlen(disk_prefix) + strlen(iso_path) - strlen(iso_prefix)+1 >= SfileadrL)
return(-1);
{ret= -1; goto ex;}
if(iso_path[strlen(iso_prefix)] == '/')
strcpy(adrc, iso_path + strlen(iso_prefix) + 1);
else
strcpy(adrc, iso_path + strlen(iso_prefix));
ret= Xorriso_make_abs_adr(xorriso, disk_prefix, adrc, disk_path, 4 | 8);
if(ret <= 0)
goto ex;
ret= 1;
ex:;
if(adrc != NULL)
free(adrc);
return(ret);
return(1);
}
@ -691,12 +714,16 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node,
int flag)
{
int ret, result, uret, follow_links, deleted= 0;
char disk_path[SfileadrL];
char *disk_path= NULL;
disk_path= TSOB_FELD(char, SfileadrL);
if(disk_path == NULL)
{ret= -1; goto ex;}
ret= Xorriso_pfx_disk_path(xorriso, iso_path, iso_prefix, disk_prefix,
disk_path, 0);
if(ret <= 0)
return(ret);
goto ex;
/* compare exclusions against disk_path resp. leaf name */
if(xorriso->disk_excl_mode&8)
@ -704,9 +731,9 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node,
else
ret= 0;
if(ret<0)
return(ret);
goto ex;
if(ret>0)
return(3);
{ret= 3; goto ex;}
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag&2))) <<28;
@ -719,7 +746,7 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node,
if(flag&1) {
if(ret<0)
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
return(ret);
goto ex;
if(ret > 0)
result= 0;
uret= Xorriso_update_interpreter(xorriso, boss_iter, node, result,
@ -731,11 +758,14 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node,
deleted= 1;
}
if(ret<0)
return(ret);
goto ex;
if(deleted)
return(2);
{ret= 2; goto ex;}
if(result&(1<<17))
return(3);
{ret= 3; goto ex;}
ex:;
if(disk_path != NULL)
free(disk_path);
return(ret);
}
@ -759,7 +789,6 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso,
char *iso_rr_path, int flag)
{
int ret= 1, deleted= 0, is_split= 0, i, loop_count, late_hardlink_update= 0;
char sfe[5*SfileadrL];
struct stat stbuf;
struct SplitparT *split_parts= NULL;
int split_count= 0;
@ -768,8 +797,8 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso,
off_t offset, bytes, total_bytes, disk_size, first_bytes;
if((compare_result&3)==3) {
sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path %s",
Text_shellsafe(disk_path, sfe, 0));
sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
xorriso->find_compare_result= -1;
ret= 3; goto ex;
@ -788,8 +817,8 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso,
if(flag & 1)
{ret= 3; goto ex;}
/* cannot open regular disk file, early eof of disk file */
sprintf(xorriso->info_text, "Problems with reading disk file %s",
Text_shellsafe(disk_path, sfe, 0));
sprintf(xorriso->info_text, "Problems with reading disk file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
xorriso->find_compare_result= -1;
ret= 1; goto ex;
@ -971,7 +1000,7 @@ overwrite:;
} else
ret= 1;
if(ret>0 && xorriso->info_text[0]) {
strcat(xorriso->info_text, Text_shellsafe(iso_rr_path, sfe, 0));
Text_shellsafe(iso_rr_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
}
ret= 1;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.02.100332"
#define Xorriso_timestamP "2011.05.02.121907"