END_TEST START_TEST(test_network_get_neightbours) { Edge *e1 = NULL, *e2 = NULL, *e3 = NULL; Node *ntmp = NULL; SList *el = NULL, *tmp = NULL; e1 = edge_create(2, 3, 1, 0); e2 = edge_create(1, 4, 1, 0); e3 = edge_create(2, 1, 1, 0); net = network_create(); network_add_edge(net, e1); network_add_edge(net, e2); network_add_edge(net, e3); el = network_neighbours(net, 2); fail_unless(!slist_is_empty(el)); tmp = el; while(tmp != NULL){ ntmp = (Node *) slist_nth_data(tmp, 0); fail_unless(*ntmp == 3 || *ntmp == 1); tmp = slist_next(tmp); } slist_free(el); network_destroy(net); }
END_TEST static void test_manifest_tell_seek(enum protocol protocol, int phase) { struct slist *slist; struct manio *manio; struct sbuf *sb=NULL; man_off_t *offset=NULL; int entries=1000; prng_init(0); base64_init(); hexmap_init(); recursive_delete(path); slist=build_manifest(path, protocol, entries, phase); fail_unless(slist!=NULL); sb=slist->head; fail_unless((manio=do_manio_open(path, "rb", protocol, phase))!=NULL); read_manifest(&sb, manio, 0, entries/2, protocol, phase); fail_unless((offset=manio_tell(manio))!=NULL); fail_unless(sb!=NULL); fail_unless(!manio_close(&manio)); fail_unless((manio=do_manio_open(path, "rb", protocol, phase))!=NULL); fail_unless(!manio_seek(manio, offset)); read_manifest(&sb, manio, entries/2, entries, protocol, phase); fail_unless(sb==NULL); fail_unless(!manio_close(&manio)); fail_unless(!manio); slist_free(&slist); man_off_t_free(&offset); tear_down(); }
void shutDown(void) { char buffer[TEMP_BUF_SIZE]; #if defined(OS_WIN32) if (!GDI_shutdown(buffer, sizeof(buffer))) { s_log(0, buffer); } #endif { slist_iterator_t it = slist_begin(s_outputs); while (it != slist_end(s_outputs)) { struct output_descriptor* od = (struct output_descriptor*) slist_iter_deref(it); output_descriptor_free(od); slist_iter_advance(&it); } slist_free(s_outputs); // TODO: why is this commented out? /*#if defined (WITH_GL) if(!GL_shutdown(buffer, sizeof(buffer))) { s_log(0, buffer); } #endif*/ } }
int main(int argc, char **argv) { int num_size = sizeof(int); slnode_t node = NULL; slist_t numbers = slist_create(free_mydata); if (numbers == NULL) return errno; for (int i = 0; i < 10; ++i) { int *num = num = (int *) malloc(num_size); if (num == NULL) { errno = ENOMEM; break; } *num = i; node = slnode_create(num, num_size); if (node == NULL) { break; } slist_add(numbers, node); } if ((node = slist_find(numbers, my_compare, (void *) 8)) != NULL) { printf("number %d was found.\n", *((int *)node->data)); } slist_free(numbers); return 0; }
int mod_load_modules(char *modules, int show) { char buf[256]; int ok = 1; slist_t *sl0, *sl; sl0 = slist_split(' ', modules); for(sl = sl0; sl && ok; sl = sl->next) { if(mod_is_loaded(sl->key)) { if(show == 2) { sprintf(buf, "Module \"%s\" has already been loaded.", sl->key); dia_message(buf, MSGTYPE_INFO); } } else { mod_load_module_manual(sl->key, show); if(!mod_is_loaded(sl->key)) ok = 0; } } slist_free(sl0); return ok; }
void queue_free (Queue *queue) { /* Precondition */ assert(queue != NULL); slist_free(queue->head); free(queue); }
/* Cleanup the data structures associated with recursive retrieving (the variables above). */ void recursive_cleanup (void) { if (undesirable_urls) { string_set_free (undesirable_urls); undesirable_urls = NULL; } if (dl_file_url_map) { free_keys_and_values (dl_file_url_map); hash_table_destroy (dl_file_url_map); dl_file_url_map = NULL; } if (dl_url_file_map) { free_keys_and_values (dl_url_file_map); hash_table_destroy (dl_url_file_map); dl_url_file_map = NULL; } undesirable_urls = NULL; free_vec (forbidden); forbidden = NULL; slist_free (downloaded_html_files); downloaded_html_files = NULL; FREE_MAYBE (base_dir); FREE_MAYBE (robots_host); first_time = 1; }
/** * Remove the search from the gui and update all widget accordingly. */ void search_gui_remove_search(search_t *search) { GtkTreeIter iter; GtkTreeModel *model; bool stopped; g_return_if_fail(search); stopped = search_gui_start_massive_update(search); if (search_gui_get_current_search() == search) { GtkTreeView *tv = GTK_TREE_VIEW(search->tree); tree_view_save_widths(tv, PROP_SEARCH_RESULTS_COL_WIDTHS); tree_view_save_visibility(tv, PROP_SEARCH_RESULTS_COL_VISIBLE); tree_view_motion_clear_callback(&tvm_search); } g_assert(0 == slist_length(search->queue)); slist_free(&search->queue); model = gtk_tree_view_get_model(tree_view_search); if (tree_find_iter_by_data(model, c_sl_sch, search, &iter)) { gtk_list_store_remove(GTK_LIST_STORE(model), &iter); } if (stopped) search_gui_end_massive_update(search); }
/* all jobs must have successors except the end job, and all jobs must have predeccessors except the start job */ int check_dependencies(struct rcps_problem *p) { int result = RCPS_CHECK_OK; int end_count = 0; int i, k; struct rcps_job *start_job; struct slist *visited; struct slist *has_predecessor = slist_new(job_compare); for (i = 0; i < p->job_count; ++i) { struct rcps_job *j = p->jobs[ i ]; //printf("check_dependencies: job %s successors: %i\n", j->name, j->successor_count); if (j->successor_count == 0) { ++end_count; } else { for (k = 0; k < j->successor_count; ++k) { //printf("check_dependencies: job %s successor[%i] = %s\n", j->name, k, j->successors[k]->name); slist_add(has_predecessor, slist_node_new(j->successors[k])); } } } if (end_count > 1) { result += RCPS_CHECK_MULTIPLE_END_JOBS; } else if (end_count == 0) { result += RCPS_CHECK_END_JOB_MISSING; } if (result == RCPS_CHECK_OK) { start_job = 0; for (i = 0; i < p->job_count; ++i) { if (!slist_find(has_predecessor, p->jobs[i])) { start_job = p->jobs[i]; } } if (start_job) { /* All other jobs should be successors of the start job */ //printf("check_dependencies: check circular\n"); visited = slist_new(job_compare); result += check_circulardependencies(start_job, visited); slist_free(visited, NULL); } else { result += RCPS_CHECK_START_JOB_MISSING; } } slist_free(has_predecessor, NULL); //printf("check_dependencies: result=%i\n", result); return result; }
/* Complexity: O(n) */ void queue_free(Queue *queue) { assert(queue != NULL); /* Only free queue container and slist container, * not slist data */ slist_free((SList *)queue); }
static void test_slist (void) { SListEntry* list = NULL; int a, b, c; slist_prepend (&list, &a); slist_prepend (&list, &b); slist_prepend (&list, &c); slist_free (list); }
/** * Free data structures used by the page cache. */ static void free_cache(struct lru_cache *cache) { hash_list_free(&cache->used); slist_free(&cache->available); gm_hash_table_destroy_null(&cache->pagnum); VMM_FREE_NULL(cache->arena, cache->pages * DBM_PBLKSIZ); WFREE_NULL(cache->numpag, cache->pages * sizeof(long)); WFREE_NULL(cache->dirty, cache->pages); cache->pages = cache->next = 0; }
/** * Free data structures used by the page cache. */ static void free_cache(struct lru_cache *cache) { hash_list_free(&cache->used); slist_free(&cache->available); htable_free_null(&cache->pagnum); VMM_FREE_NULL(cache->arena, cache->pages * DBM_PBLKSIZ); WFREE_ARRAY_NULL(cache->numpag, cache->pages); WFREE_NULL(cache->dirty, cache->pages); cache->pages = cache->next = 0; }
void test_slist_create(void) { test_slist = slist_create(); assert_true(test_slist != NULL); assert_true(slist_size(test_slist) == 0); assert_true(slist_is_empty(test_slist)); slist_free(test_slist); test_slist = NULL; }
/** \brief free's all memory in EEG-struct. including the data \param eeg */ void eeg_free( EEG *eeg ){ safer_free( eeg->filename ); safer_free( eeg->comment ); array_free( eeg->times); array_free( eeg->data ); array_free( eeg->markers ); array_free( eeg->marker_type ); slist_free( eeg->marker_types ); if( eeg->additional ) free( eeg->additional ); safer_free( eeg->chaninfo ); safer_free( eeg ); }
static void run_test(int expected_ret, int manio_entries, int async_read_write_callback(struct async *as), void setup_asfds_callback(struct asfd *asfd, struct asfd *chfd, struct slist *slist)) { struct asfd *asfd; struct asfd *chfd; struct async *as; struct sdirs *sdirs; struct conf **confs; struct slist *slist=NULL; prng_init(0); base64_init(); hexmap_init(); setup(&as, &sdirs, &confs); asfd=asfd_mock_setup(&areads, &awrites); chfd=asfd_mock_setup(&creads, &cwrites); fail_unless((asfd->desc=strdup_w("a", __func__))!=NULL); fail_unless((chfd->desc=strdup_w("c", __func__))!=NULL); as->asfd_add(as, asfd); as->asfd_add(as, chfd); as->read_write=async_read_write_callback; if(manio_entries) slist=build_manifest(sdirs->phase1data, PROTO_2, manio_entries, 1 /*phase*/); setup_asfds_callback(asfd, chfd, slist); fail_unless(do_backup_phase2_server_protocol2( as, chfd, sdirs, 0, // resume confs )==expected_ret); if(!expected_ret) { // FIX THIS: Should check for the presence and correctness of // changed and unchanged manios. } asfd_free(&asfd); asfd_free(&chfd); asfd_mock_teardown(&areads, &awrites); asfd_mock_teardown(&creads, &cwrites); slist_free(&slist); tear_down(&as, &sdirs, &confs); }
/** * Dispose of all the items remaining in the list, applying the supplied free * callback on all the items, then freeing the slist_t container. */ void slist_free_all(slist_t **slist_ptr, slist_destroy_cb freecb) { g_assert(slist_ptr); g_assert(freecb); if (*slist_ptr) { slist_t *slist = *slist_ptr; slist_check(slist); G_SLIST_FOREACH_WITH_DATA(slist->head, slist_freecb_wrapper, cast_func_to_pointer(freecb)); slist_free(slist_ptr); } }
void configs_cleanup(void) { if (!configs) return; SLIST_ITERATOR p = slist_head(configs, NULL); while(p != NULL) { struct ConfigItem *item = *(struct ConfigItem **)slist_get(p); free(item); p = slist_next(p); } slist_free(configs); }
static void cleanup(void) { char *command; if(lastcommand != NULL) { free(lastcommand); lastcommand = NULL; } if(commands != NULL) { while((command = slist_head_pop(commands)) != NULL) { free(command); } slist_free(commands); commands = NULL; } if(outfile_fd != -1) { close(outfile_fd); outfile_fd = -1; } if(scamper_fd != -1) { close(scamper_fd); scamper_fd = -1; } if(readbuf != NULL) { free(readbuf); readbuf = NULL; } if(stdinbuf != NULL) { free(stdinbuf); stdinbuf = NULL; } return; }
int mod_unload_modules(char *modules) { int ok = 1; slist_t *sl0, *sl; sl0 = slist_reverse(slist_split(' ', modules)); for(sl = sl0; sl; sl = sl->next) { if(mod_is_loaded(sl->key)) { mod_unload_module(sl->key); if(mod_is_loaded(sl->key)) ok = 0; } } slist_free(sl0); return ok; }
void hash_table_clear(struct hash_table *m) { if (!m) { return; } m->hasher = NULL; m->comparer = NULL; for (size_t i = 0; i < m->capacity; ++i) { if (m->table[i]) { slist_free(m->table[i]); } } free(m->table); m->table = NULL; m->capacity = 0; m->count = 0; m->load_factor = 0; }
static int actual_restore(struct asfd *asfd, struct bu *bu, const char *manifest, regex_t *regex, int srestore, enum action act, struct sdirs *sdirs, enum cntr_status cntr_status, struct conf **cconfs) { int ret=-1; int do_restore_stream=1; // For out-of-sequence directory restoring so that the // timestamps come out right: struct slist *slist=NULL; if(linkhash_init() || !(slist=slist_alloc())) goto end; if(get_protocol(cconfs)==PROTO_2) { switch(maybe_restore_spool(asfd, manifest, sdirs, bu, srestore, regex, cconfs, slist, act, cntr_status)) { case 1: do_restore_stream=0; break; case 0: do_restore_stream=1; break; default: goto end; // Error; } } if(do_restore_stream && restore_stream(asfd, sdirs, slist, bu, manifest, regex, srestore, cconfs, act, cntr_status)) goto end; if(restore_remaining_dirs(asfd, bu, slist, act, sdirs, cntr_status, cconfs)) goto end; // Restore has nearly completed OK. ret=restore_end(asfd, cconfs); cntr_print(get_cntr(cconfs), act); cntr_stats_to_file(get_cntr(cconfs), bu->path, act, cconfs); end: slist_free(&slist); linkhash_free(); return ret; }
/* Cleanup the data structures associated with recursive retrieving (the variables above). */ void convert_cleanup (void) { if (dl_file_url_map) { free_keys_and_values (dl_file_url_map); hash_table_destroy (dl_file_url_map); dl_file_url_map = NULL; } if (dl_url_file_map) { free_keys_and_values (dl_url_file_map); hash_table_destroy (dl_url_file_map); dl_url_file_map = NULL; } if (downloaded_html_set) string_set_free (downloaded_html_set); slist_free (downloaded_html_list); downloaded_html_list = NULL; }
/* Para testing de memoria */ void network_memory_test(void){ /* Codigo que deberia correr sin memory leaks */ Edge *e1 = NULL, *e2 = NULL, *e3 = NULL, *e4 = NULL, *etmp = NULL; Node *ntmp = NULL; SList *el = NULL, *nl = NULL, *tmp = NULL; e1 = edge_create(0, 1, 1, 0); e2 = edge_create(0, 2, 4, 0); e3 = edge_create(2, 3, 6, 0); e4 = edge_create(2, 0, 0, 0); net = network_create(); network_add_edge(net, e1); network_add_edge(net, e2); network_add_edge(net, e3); network_add_edge(net, e4); el = network_get_edges(net, 0); tmp = el; while(tmp != NULL){ etmp = (Edge *) slist_nth_data(tmp, 0); edge_pprint(etmp); tmp = slist_next(tmp); } nl = network_neighbours(net, 2); printf("Vecinos del nodo: 2\n"); tmp = nl; while(tmp != NULL){ ntmp = (Node *) slist_nth_data(tmp, 0); tmp = slist_next(tmp); printf(" %d\n", *ntmp); } slist_free(nl); network_destroy(net); }
static void run_test(int expected_ret, int slist_entries, enum protocol protocol, void setup_callback(struct asfd *asfd, struct slist *slist)) { int result; struct slist *slist=NULL; const char *conffile=BASE "/burp.conf"; struct asfd *asfd; struct conf **confs; const char *buf; if(protocol==PROTO_1) buf=MIN_CLIENT_CONF "protocol=1\n"; else buf=MIN_CLIENT_CONF "protocol=2\n"; base64_init(); asfd=asfd_mock_setup(&reads, &writes); confs=setup_conf(); fail_unless(recursive_delete(BASE)==0); build_file(conffile, buf); fail_unless(!conf_load_global_only(conffile, confs)); if(slist_entries) slist=build_slist_phase1(BASE, protocol, slist_entries); setup_callback(asfd, slist); result=do_restore_client(asfd, confs, ACTION_RESTORE, 0 /* vss_restore */); fail_unless(result==expected_ret); slist_free(&slist); tear_down(&asfd, &confs); }
static void run_test( int expected_result, int entries, void setup_datadir_tmp_callback( struct slist *slist, struct fdirs *fdirs, struct conf **confs)) { struct conf **confs; struct sdirs *sdirs; struct fdirs *fdirs; struct slist *slist; setup(&sdirs, &fdirs, &confs); build_storage_dirs(sdirs, sd1, ARR_LEN(sd1)); slist=build_manifest( fdirs->manifest, PROTO_1, entries, /*phase*/ 3); setup_datadir_tmp_callback(slist, fdirs, confs); clock_t start; clock_t diff; start = clock(); fail_unless(backup_phase4_server_protocol1(sdirs, confs) ==expected_result); diff = clock() - start; int msec = diff * 1000 / CLOCKS_PER_SEC; printf("%d.%d\n", msec/1000, msec%1000); log_fzp_set(NULL, confs); assert_datadir(slist, fdirs); slist_free(&slist); tear_down(&sdirs, &fdirs, &confs); }
/* * scamper_writebuf_free * */ void scamper_writebuf_free(scamper_writebuf_t *wb) { struct iovec *iov; if(wb == NULL) return; if(wb->fdn != NULL) scamper_fd_write_pause(wb->fdn); if(wb->iovs != NULL) { while((iov = slist_head_pop(wb->iovs)) != NULL) { free(iov->iov_base); free(iov); } slist_free(wb->iovs); } free(wb); return; }
/** A generic sort routine to sort several different * types of arrays, in place. * \param player the player executing the sort. * \param s the array to sort. * \param n number of elements in array s * \param sort_type the string that describes the sort type. */ void do_gensort(dbref player, char *keys[], char *strs[], int n, SortType sort_type) { s_rec *sp; ListTypeInfo *lti; int i; lti = get_list_type_info(sort_type); sp = slist_build(player, keys, strs, n, lti); slist_qsort(sp, n, lti); /* Change keys and strs around. */ for (i = 0; i < n; i++) { keys[i] = sp[i].val; if (strs) { strs[i] = sp[i].ptr; } } /* Free the s_rec list */ slist_free(sp, n, lti); free_list_type_info(lti); }
static #endif int do_backup_phase2_server_protocol2(struct async *as, struct asfd *chfd, struct sdirs *sdirs, int resume, struct conf **confs) { int ret=-1; uint8_t end_flags=0; struct slist *slist=NULL; struct iobuf wbuf; struct dpth *dpth=NULL; man_off_t *p1pos=NULL; struct manios *manios=NULL; // This is used to tell the client that a number of consecutive blocks // have been found and can be freed. uint64_t wrap_up=0; struct asfd *asfd=NULL; struct cntr *cntr=NULL; struct sbuf *csb=NULL; uint64_t file_no=1; if(!as) { logp("async not provided to %s()\n", __func__); goto end; } if(!sdirs) { logp("sdirs not provided to %s()\n", __func__); goto end; } if(!confs) { logp("confs not provided to %s()\n", __func__); goto end; } asfd=as->asfd; if(!asfd) { logp("asfd not provided to %s()\n", __func__); goto end; } if(!chfd) { logp("chfd not provided to %s()\n", __func__); goto end; } cntr=get_cntr(confs); if(get_int(confs[OPT_BREAKPOINT])>=2000 && get_int(confs[OPT_BREAKPOINT])<3000) { breaking=get_int(confs[OPT_BREAKPOINT]); breakcount=breaking-2000; } logp("Phase 2 begin (recv backup data)\n"); if(!(dpth=dpth_alloc()) || dpth_protocol2_init(dpth, sdirs->data, get_string(confs[OPT_CNAME]), sdirs->cfiles, get_int(confs[OPT_MAX_STORAGE_SUBDIRS]))) goto end; if(resume && !(p1pos=do_resume(sdirs, dpth, confs))) goto end; if(!(manios=manios_open_phase2(sdirs, p1pos, PROTO_2)) || !(slist=slist_alloc()) || !(csb=sbuf_alloc(PROTO_2))) goto end; iobuf_free_content(asfd->rbuf); memset(&wbuf, 0, sizeof(struct iobuf)); while(!(end_flags&END_BACKUP)) { if(maybe_add_from_scan(manios, slist, chfd, &csb)) goto end; if(!wbuf.len) { if(get_wbuf_from_sigs(&wbuf, slist, &end_flags)) goto end; if(!wbuf.len) { get_wbuf_from_files(&wbuf, slist, manios, &end_flags, &file_no); } } if(wbuf.len && asfd->append_all_to_write_buffer(asfd, &wbuf)==APPEND_ERROR) goto end; if(append_for_champ_chooser(chfd, slist->blist, end_flags)) goto end; if(as->read_write(as)) { logp("error from as->read_write in %s\n", __func__); goto end; } while(asfd->rbuf->buf) { if(deal_with_read(asfd->rbuf, slist, cntr, &end_flags, dpth)) goto end; // Get as much out of the readbuf as possible. if(asfd->parse_readbuf(asfd)) goto end; } while(chfd->rbuf->buf) { if(deal_with_read_from_chfd(chfd, slist->blist, &wrap_up, dpth, cntr)) goto end; // Get as much out of the readbuf as possible. if(chfd->parse_readbuf(chfd)) goto end; } if(write_to_changed_file(asfd, chfd, manios, slist, end_flags)) goto end; } // Hack: If there are some entries left after the last entry that // contains block data, it will not be written to the changed file // yet because the last entry of block data has not had // sb->protocol2->bend set. if(slist->head && slist->head->next) { struct sbuf *sb=NULL; sb=slist->head; slist->head=sb->next; sbuf_free(&sb); if(write_to_changed_file(asfd, chfd, manios, slist, end_flags)) goto end; } if(manios_close(&manios)) goto end; if(check_for_missing_work_in_slist(slist)) goto end; // Need to release the last left. There should be one at most. if(dpth->head && dpth->head->next) { logp("ERROR: More data locks remaining after: %s\n", dpth->head->save_path); goto end; } if(dpth_release_all(dpth)) goto end; ret=0; end: logp("End backup\n"); sbuf_free(&csb); slist_free(&slist); if(asfd) iobuf_free_content(asfd->rbuf); if(chfd) iobuf_free_content(chfd->rbuf); dpth_free(&dpth); manios_close(&manios); man_off_t_free(&p1pos); return ret; }
int backup_phase2_server(struct async *as, struct sdirs *sdirs, const char *manifest_dir, int resume, struct conf *conf) { int ret=-1; int sigs_end=0; int backup_end=0; int requests_end=0; int blk_requests_end=0; struct slist *slist=NULL; struct blist *blist=NULL; struct iobuf *wbuf=NULL; struct dpth *dpth=NULL; struct manio *cmanio=NULL; // current manifest struct manio *p1manio=NULL; // phase1 scan manifest struct manio *chmanio=NULL; // changed manifest struct manio *unmanio=NULL; // unchanged manifest // This is used to tell the client that a number of consecutive blocks // have been found and can be freed. uint64_t wrap_up=0; // Main fd is first in the list. struct asfd *asfd=as->asfd; // Champ chooser fd is second in the list. struct asfd *chfd=asfd->next; logp("Phase 2 begin (recv backup data)\n"); //if(champ_chooser_init(sdirs->data, conf) if(!(cmanio=manio_alloc()) || !(p1manio=manio_alloc()) || !(chmanio=manio_alloc()) || !(unmanio=manio_alloc()) || manio_init_read(cmanio, sdirs->cmanifest) || manio_init_read(p1manio, sdirs->phase1data) || manio_init_write(chmanio, sdirs->changed) || manio_init_write(unmanio, sdirs->unchanged) || !(slist=slist_alloc()) || !(blist=blist_alloc()) || !(wbuf=iobuf_alloc()) || !(dpth=dpth_alloc(sdirs->data)) || dpth_init(dpth)) goto end; // The phase1 manifest looks the same as a burp1 one. manio_set_protocol(p1manio, PROTO_BURP1); while(!backup_end) { if(maybe_add_from_scan(asfd, p1manio, cmanio, unmanio, slist, conf)) goto end; if(!wbuf->len) { if(get_wbuf_from_sigs(wbuf, slist, blist, sigs_end, &blk_requests_end, dpth, conf)) goto end; if(!wbuf->len) { get_wbuf_from_files(wbuf, slist, p1manio, &requests_end); } } if(wbuf->len) asfd->append_all_to_write_buffer(asfd, wbuf); append_for_champ_chooser(chfd, blist, sigs_end); if(as->read_write(as)) { logp("error in %s\n", __func__); goto end; } while(asfd->rbuf->buf) { if(deal_with_read(asfd->rbuf, slist, blist, conf, &sigs_end, &backup_end, dpth)) goto end; // Get as much out of the // readbuf as possible. if(asfd->parse_readbuf(asfd)) goto end; } while(chfd->rbuf->buf) { if(deal_with_read_from_chfd(asfd, chfd, blist, &wrap_up, dpth)) goto end; // Get as much out of the // readbuf as possible. if(chfd->parse_readbuf(chfd)) goto end; } if(write_to_changed_file(asfd, chfd, chmanio, slist, blist, dpth, backup_end, conf)) goto end; } // Hack: If there are some entries left after the last entry that // contains block data, it will not be written to the changed file // yet because the last entry of block data has not had // sb->burp2->bend set. if(slist->head && slist->head->next) { slist->head=slist->head->next; if(write_to_changed_file(asfd, chfd, chmanio, slist, blist, dpth, backup_end, conf)) goto end; } if(manio_close(unmanio) || manio_close(chmanio)) goto end; if(blist->head) { logp("ERROR: finishing but still want block: %lu\n", blist->head->index); goto end; } // Need to release the last left. There should be one at most. if(dpth->head && dpth->head->next) { logp("ERROR: More data locks remaining after: %s\n", dpth->head->save_path); goto end; } if(dpth_release_all(dpth)) goto end; ret=0; end: logp("End backup\n"); slist_free(slist); blist_free(blist); iobuf_free_content(asfd->rbuf); iobuf_free_content(chfd->rbuf); // Write buffer did not allocate 'buf'. if(wbuf) wbuf->buf=NULL; iobuf_free(wbuf); dpth_release_all(dpth); dpth_free(&dpth); manio_free(&cmanio); manio_free(&p1manio); manio_free(&chmanio); manio_free(&unmanio); return ret; }