Use pointer to stat struct for id_list.

This commit is contained in:
Klaas Freitag 2013-04-22 10:22:20 +02:00
parent a496bb0e13
commit 64927899af
2 changed files with 20 additions and 7 deletions

View File

@ -762,10 +762,17 @@ int csync_commit(CSYNC *ctx) {
/* free memory */
c_rbtree_free(ctx->local.tree);
c_list_free(ctx->local.list);
// c_list_free(ctx->local.id_list);
c_list_free(ctx->local.id_list);
c_rbtree_free(ctx->remote.tree);
c_list_free(ctx->remote.list);
// c_list_free(ctx->remote.id_list);
c_list_free(ctx->remote.id_list);
ctx->remote.list = 0;
ctx->remote.id_list = 0;
ctx->local.list = 0;
ctx->local.id_list = 0;
ctx->remote.read_from_db = 0;
/* create/load statedb */
if (! csync_is_statedb_disabled(ctx)) {
@ -801,6 +808,8 @@ int csync_commit(CSYNC *ctx) {
}
ctx->status = CSYNC_STATUS_INIT;
ctx->error_code = CSYNC_ERR_NONE;
SAFE_FREE(ctx->error_string);
out:
return rc;
}

View File

@ -44,25 +44,29 @@
static int _csync_cleanup_cmp(const void *a, const void *b) {
csync_file_stat_t *st_a, *st_b;
st_a = (csync_file_stat_t *) a;
st_b = (csync_file_stat_t *) b;
st_a = *((csync_file_stat_t **) a);
st_b = *((csync_file_stat_t **) b);
return strcmp(st_a->path, st_b->path);
}
static void _store_id_update(CSYNC *ctx, csync_file_stat_t *st) {
c_list_t *list = NULL;
csync_file_stat_t **pst;
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "SYNCED remember dir: %s", st->path);
pst = c_malloc(sizeof(csync_file_stat_t*));
*pst = st;
switch (ctx->current) {
case LOCAL_REPLICA:
list = c_list_prepend(ctx->local.id_list, (void*)st);
list = c_list_prepend(ctx->local.id_list, (void*)pst);
if( list != NULL ) {
ctx->local.id_list = list;
}
break;
case REMOTE_REPLICA:
list = c_list_prepend(ctx->remote.id_list, (void*)st);
list = c_list_prepend(ctx->remote.id_list, (void*)pst);
if(list != NULL ) {
ctx->remote.id_list = list;
}
@ -1292,7 +1296,7 @@ int csync_correct_id(CSYNC *ctx) {
for (walk = c_list_last(list); walk != NULL; walk = c_list_prev(walk)) {
csync_file_stat_t *st = NULL;
st = (csync_file_stat_t *) walk->data;
st = *((csync_file_stat_t **) walk->data);
if( st->type == CSYNC_FTW_TYPE_FILE ) {
path = c_dirname( st->path );
} else if( st->type == CSYNC_FTW_TYPE_DIR ) {