for(size_t i=0;i<torrent_p->files->size;i++) {
p = torrent_p->files->map[i];
if(p!=NULL) {
- if(
- ((ret = torrent_add_file_by_root(new,p))<=0) ||
- ((ret = torrent_add_file_by_path(new,p))<=0)
- ) {
+ if((ret = torrent_add_file_by_root(new,p))<=0) {
if(ret<0) { return -1; }
- hashmap_clear(new);
- hashmap_free(new);
- return torrent_files_resize(torrent_p,new_size<<1);
+ goto resize;
+ }
+
+ if(ret==0) {
+ if((ret = torrent_add_file_by_path(new,p))<=0) { goto resize; }
}
}
}
hashmap_free(old);
return 1;
+resize:
+ if(ret<0) { return -1; }
+ hashmap_clear(new);
+ hashmap_free(new);
+ return torrent_files_resize(torrent_p,new_size<<1);
}