diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/test/xorriso.c index 480a41b0..cbad0cfa 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/test/xorriso.c @@ -3468,59 +3468,6 @@ int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, } -int Xorriso_match_file(struct XorrisO *xorriso, char *to_match, char *adr, - int flag) -/* - bit0= match under fsm rules: with search_mode 0 : do not accept partial match - bit1= with xorriso->search_mode==4 : do not check for '/' - bit2= single level bit for Xorriso_regexec() -*/ -/* return: - <0 error - 0 no match - 1 match - 2 match with request to break volume loop -*/ -{ - int ret,l,failed_at; - char *cpt; - - l= strlen(to_match); - if(xorriso->search_mode==0) { - if(flag&1) { - if(strcmp(adr,to_match)==0) - return(2); - } else { - if(strncmp(adr,to_match,l)==0) - if(adr[l]=='/'||adr[l]==0) - return(2); - } - l= strlen(adr); - if(strncmp(to_match,adr,l)==0) - if(to_match[l]=='/'||to_match[l]==0) { - return(1); - } - } else if(xorriso->search_mode==1) { - if(strstr(to_match,adr)!=NULL) - return(1); - } else if(xorriso->search_mode>=2 && xorriso->search_mode<=4) { - if(xorriso->search_mode==4 && !(flag&2)) { - cpt= strrchr(to_match,'/'); - if(cpt==NULL) - cpt= to_match; - else - cpt++; - } else - cpt= to_match; - ret= Xorriso_regexec(xorriso,cpt,&failed_at,1|(flag&4)); - if(ret==0) - return(1); - xorriso->re_failed_at= failed_at; - } - return(0); -} - - /* @param flag bit0= simple readlink(): no normalization, no multi-hop */ int Xorriso_resolve_link(struct XorrisO *xorriso, @@ -4066,10 +4013,24 @@ int Xorriso_obtain_pattern_files_x( int *dive_count, int flag) { int ret, failed_at, follow_mount, follow_links; - char adr[SfileadrL], name[SfileadrL], path_data[SfileadrL], *path; struct DirseQ *dirseq= NULL; struct stat stbuf; dev_t dir_dev; + char *path; + +#ifdef Xorriso_fat_local_meM + char adr[SfileadrL], name[SfileadrL], path_data[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *adr= NULL, *name= NULL, *path_data= NULL; + + adr= malloc(SfileadrL); + name= malloc(SfileadrL); + path_data= malloc(SfileadrL); + if(adr==NULL || name==NULL || path_data==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ follow_mount= (xorriso->do_follow_mount || xorriso->do_follow_pattern); follow_links= (xorriso->do_follow_links || xorriso->do_follow_pattern); @@ -4154,6 +4115,16 @@ int Xorriso_obtain_pattern_files_x( } ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(adr!=NULL) + free(adr); + if(name!=NULL) + free(name); + if(path_data!=NULL) + free(path_data); +#endif /* ! Xorriso_fat_local_meM */ + Dirseq_destroy(&dirseq,0); if(flag&2) (*dive_count)--; @@ -4221,6 +4192,20 @@ int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag) } +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag) +{ + if(to_free!=NULL) + if(*to_free!=NULL) { + /* Eventual memory sacrifice to get on going */ + free(*to_free); + *to_free= NULL; + } + sprintf(xorriso->info_text, "Out of virtual memory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "ABORT", 0); + return(1); +} + + int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, int count, char ***filev, int flag) { @@ -4803,7 +4788,6 @@ int Xorriso_show_dux_subs(struct XorrisO *xorriso, int flag) { int i, ret, no_sort= 0, filec= 0, l, j, fc, no_dive, is_link; - char path[SfileadrL], show_path[SfileadrL], name[SfileadrL], sfe[5*SfileadrL]; char **filev= NULL, *namept; off_t sub_size, report_size, mem= 0; struct DirseQ *dirseq= NULL; @@ -4811,6 +4795,22 @@ int Xorriso_show_dux_subs(struct XorrisO *xorriso, dev_t dir_dev; struct LinkiteM *own_link_stack; +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], show_path[SfileadrL], name[SfileadrL], sfe[5*SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *show_path= NULL, *name= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + name= malloc(SfileadrL); + if(path==NULL || show_path==NULL || name==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + own_link_stack= link_stack; namept= name; *size= 0; @@ -5017,6 +5017,18 @@ revoke_sorting:; ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); + if(name!=NULL) + free(name); +#endif /* ! Xorriso_fat_local_meM */ + Linkitem_reset_stack(&own_link_stack, link_stack, 0); Dirseq_destroy(&dirseq, 0); if(filev!=NULL) { @@ -5314,9 +5326,27 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, int ret,is_link, no_dive; struct DirseQ *dirseq= NULL; struct stat stbuf; - char name[SfileadrL], path[SfileadrL], sfe[5*SfileadrL], *namept; - char abs_dir_path_data[SfileadrL], abs_path[SfileadrL], *abs_dir_path; struct LinkiteM *own_link_stack; + char *abs_dir_path, *namept; + +#ifdef Xorriso_fat_local_meM + char name[SfileadrL], path[SfileadrL], sfe[5*SfileadrL]; + char abs_dir_path_data[SfileadrL], abs_path[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *name= NULL, *path= NULL, *sfe= NULL; + char *abs_dir_path_data= NULL, *abs_path= NULL; + + sfe= malloc(5*SfileadrL); + name= malloc(SfileadrL); + path= malloc(SfileadrL); + abs_dir_path_data= malloc(SfileadrL); + abs_path= malloc(SfileadrL); + if(name==NULL || sfe==NULL || path==NULL || + abs_dir_path_data==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ own_link_stack= link_stack; abs_dir_path= abs_dir_parm; @@ -5411,6 +5441,20 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(name!=NULL) + free(name); + if(path!=NULL) + free(path); + if(abs_dir_path_data!=NULL) + free(abs_dir_path_data); + if(abs_path!=NULL) + free(abs_path); +#endif /* ! Xorriso_fat_local_meM */ + Dirseq_destroy(&dirseq, 0); return(ret); } diff --git a/libisoburn/trunk/test/xorriso_private.h b/libisoburn/trunk/test/xorriso_private.h index 9f50d2af..be9f064d 100644 --- a/libisoburn/trunk/test/xorriso_private.h +++ b/libisoburn/trunk/test/xorriso_private.h @@ -263,6 +263,9 @@ int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, /* return: 2= bourne_expr is surely a constant */ int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag); +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, + int flag); + int Sfile_str(char target[SfileadrL], char *source, int flag); diff --git a/libisoburn/trunk/test/xorriso_timestamp.h b/libisoburn/trunk/test/xorriso_timestamp.h index 7542d7da..248528bd 100644 --- a/libisoburn/trunk/test/xorriso_timestamp.h +++ b/libisoburn/trunk/test/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2007.12.26.160040" +#define Xorriso_timestamP "2007.12.28.132741" diff --git a/libisoburn/trunk/test/xorrisoburn.c b/libisoburn/trunk/test/xorrisoburn.c index 1a79f4ab..a0e37453 100644 --- a/libisoburn/trunk/test/xorrisoburn.c +++ b/libisoburn/trunk/test/xorrisoburn.c @@ -744,30 +744,50 @@ int Xorriso_add_tree(struct XorrisO *xorriso, struct iso_tree_node_dir *dir, int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0; int do_not_dive; struct DirseQ *dirseq= NULL; - char sfe[5*SfileadrL], sfe2[5*SfileadrL]; - char disk_path[2*SfileadrL], img_path[2*SfileadrL], link_target[SfileadrL]; char *name, *img_name, *srcpt; struct stat stbuf, hstbuf; dev_t dir_dev; struct LinkiteM *own_link_stack; +#ifdef Xorriso_fat_local_meM + char sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char disk_path[2*SfileadrL], img_path[2*SfileadrL], link_target[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + + char *sfe= NULL, *sfe2= NULL; + char *disk_path= NULL, *img_path= NULL, *link_target= NULL; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sfe2= malloc(5*SfileadrL); + disk_path= malloc(2*SfileadrL); + img_path= malloc(2*SfileadrL); + link_target= malloc(SfileadrL); + if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL || + link_target==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + own_link_stack= link_stack; ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) - return(ret); + goto ex; if(lstat(disk_dir_path, &stbuf)==-1) goto cannot_open_dir; dir_dev= stbuf.st_dev; if(S_ISLNK(stbuf.st_mode)) { if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) - return(2); + {ret= 2; goto ex;} if(stat(disk_dir_path, &stbuf)==-1) goto cannot_open_dir; if(dir_dev != stbuf.st_dev && !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) - return(2); + {ret= 2; goto ex;} } ret= Dirseq_new(&dirseq, disk_dir_path, 1); if(ret<0) { @@ -933,6 +953,20 @@ was_problem:; ret= 1; ex: + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(sfe2!=NULL) + free(sfe2); + if(disk_path!=NULL) + free(disk_path); + if(img_path!=NULL) + free(img_path); + if(link_target!=NULL) + free(link_target); +#endif /* ! Xorriso_fat_local_meM */ + Xorriso_process_msg_queues(xorriso,0); Linkitem_reset_stack(&own_link_stack, link_stack, 0); Dirseq_destroy(&dirseq, 0); @@ -1602,7 +1636,21 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, struct iso_tree_node_dir *boss_node, *root_dir; struct iso_tree_iter *iter= NULL; struct iso_volume *volume; - char sfe[5*SfileadrL], sub_path[2*SfileadrL], *sub_name, *name; + char *sub_name, *name; + +#ifdef Xorriso_fat_local_meM + char sfe[5*SfileadrL], sub_path[2*SfileadrL]; +#else + char *sfe= NULL, *sub_path= NULL; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sub_path= malloc(2*SfileadrL); + if(sfe==NULL || sub_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) @@ -1617,7 +1665,7 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, if(((void *) root_dir) == ((void *) victim_node)) { sprintf(xorriso->info_text, "May not delete root directory"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); + {ret= 0; goto ex;} } if(LIBISO_ISDIR(victim_node)) @@ -1758,6 +1806,14 @@ dir_not_removed:; xorriso->volset_change_pending= 1; ret= 1+!!is_dir; ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(sub_path!=NULL) + free(sub_path); +#endif /* ! Xorriso_fat_local_meM */ + if(iter!=NULL) iso_tree_iter_free(iter); return(ret); @@ -1833,9 +1889,24 @@ int Xorriso_show_du_subs(struct XorrisO *xorriso, int i, ret, no_sort= 0, filec= 0, l; struct iso_tree_iter *iter= NULL; struct iso_tree_node *node, **node_array= NULL; - char path[SfileadrL], show_path[SfileadrL], *name, sfe[5*SfileadrL]; + char *name; off_t sub_size, report_size, mem= 0; +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], show_path[SfileadrL], sfe[5*SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *show_path= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + if(path==NULL || show_path==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + *size= 0; iter= iso_tree_node_children(dir_node); if(iter==NULL) { @@ -1935,6 +2006,16 @@ much_too_long:; } ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); +#endif /* ! Xorriso_fat_local_meM */ + if(iter!=NULL) iso_tree_iter_free(iter); if(node_array!=NULL) @@ -2461,7 +2542,20 @@ int Xorriso_obtain_pattern_files_i( int ret, failed_at; struct iso_tree_iter *iter= NULL; struct iso_tree_node *node; - char adr[SfileadrL], *name; + char *name; + +#ifdef Xorriso_fat_local_meM + char adr[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *adr= NULL; + + adr= malloc(SfileadrL); + if(adr==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + if(!(flag&2)) *dive_count= 0; @@ -2510,6 +2604,12 @@ int Xorriso_obtain_pattern_files_i( } ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(adr!=NULL) + free(adr); +#endif /* ! Xorriso_fat_local_meM */ + if(flag&2) (*dive_count)--; return(ret); @@ -2728,7 +2828,20 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, struct iso_tree_node *node; struct iso_volume *volume; struct stat stbuf; - char *name, path[SfileadrL], sfe[5*SfileadrL]; + char *name; + +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], sfe[5*SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + if(sfe==NULL || path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ dir_node= (struct iso_tree_node_dir *) dir_node_generic; if(dir_node==NULL) { @@ -2799,6 +2912,14 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, ret= 1; ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); +#endif /* ! Xorriso_fat_local_meM */ + Xorriso_process_msg_queues(xorriso,0); if(iter!=NULL) iso_tree_iter_free(iter);