mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 08:47:22 +03:00
Static functions should all start with an underscore.
For better readablity...
This commit is contained in:
parent
2ccbaa05b6
commit
e2b049c935
13 changed files with 75 additions and 75 deletions
14
src/csync.c
14
src/csync.c
|
@ -47,7 +47,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.api"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int key_cmp(const void *key, const void *data) {
|
||||
static int _key_cmp(const void *key, const void *data) {
|
||||
uint64_t a;
|
||||
csync_file_stat_t *b;
|
||||
|
||||
|
@ -63,7 +63,7 @@ static int key_cmp(const void *key, const void *data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int data_cmp(const void *key, const void *data) {
|
||||
static int _data_cmp(const void *key, const void *data) {
|
||||
csync_file_stat_t *a, *b;
|
||||
|
||||
a = (csync_file_stat_t *) key;
|
||||
|
@ -261,12 +261,12 @@ int csync_init(CSYNC *ctx) {
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (c_rbtree_create(&ctx->local.tree, key_cmp, data_cmp) < 0) {
|
||||
if (c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (c_rbtree_create(&ctx->remote.tree, key_cmp, data_cmp) < 0) {
|
||||
if (c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ int csync_propagate(CSYNC *ctx) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void tree_destructor(void *data) {
|
||||
static void _tree_destructor(void *data) {
|
||||
csync_file_stat_t *freedata = NULL;
|
||||
|
||||
freedata = (csync_file_stat_t *) data;
|
||||
|
@ -481,11 +481,11 @@ int csync_destroy(CSYNC *ctx) {
|
|||
|
||||
/* destroy the rbtrees */
|
||||
if (c_rbtree_size(ctx->local.tree) > 0) {
|
||||
c_rbtree_destroy(ctx->local.tree, tree_destructor);
|
||||
c_rbtree_destroy(ctx->local.tree, _tree_destructor);
|
||||
}
|
||||
|
||||
if (c_rbtree_size(ctx->remote.tree) > 0) {
|
||||
c_rbtree_destroy(ctx->remote.tree, tree_destructor);
|
||||
c_rbtree_destroy(ctx->remote.tree, _tree_destructor);
|
||||
}
|
||||
|
||||
c_rbtree_free(ctx->local.tree);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.config"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int csync_config_copy_default (const char *config) {
|
||||
static int _csync_config_copy_default (const char *config) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Copy %s/config/%s to %s", SYSCONFDIR,
|
||||
CSYNC_CONF_FILE, config);
|
||||
if (c_copy(SYSCONFDIR "/csync/" CSYNC_CONF_FILE, config, 0644) < 0) {
|
||||
|
@ -46,7 +46,7 @@ int csync_config_load(CSYNC *ctx, const char *config) {
|
|||
|
||||
/* copy default config, if no config exists */
|
||||
if (! c_isfile(config)) {
|
||||
if (csync_config_copy_default(config) < 0) {
|
||||
if (_csync_config_copy_default(config) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.exclude"
|
||||
#include "csync_log.h"
|
||||
|
||||
static void csync_exclude_add(CSYNC *ctx, const char *string) {
|
||||
static void _csync_exclude_add(CSYNC *ctx, const char *string) {
|
||||
if (ctx->excludes == NULL) {
|
||||
ctx->excludes = c_strlist_new(32);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ int csync_exclude_load(CSYNC *ctx, const char *fname) {
|
|||
buf[i] = '\0';
|
||||
if (*entry != '#' || *entry == '\n') {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Adding entry: %s", entry);
|
||||
csync_exclude_add(ctx, entry);
|
||||
_csync_exclude_add(ctx, entry);
|
||||
}
|
||||
}
|
||||
entry = buf + i + 1;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#define BUF_SIZE 16
|
||||
|
||||
static int csync_journal_check(const char *journal) {
|
||||
static int _csync_journal_check(const char *journal) {
|
||||
int fd = -1;
|
||||
char buf[BUF_SIZE] = {0};
|
||||
sqlite3 *db = NULL;
|
||||
|
@ -75,7 +75,7 @@ static int csync_journal_check(const char *journal) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int csync_journal_is_empty(CSYNC *ctx) {
|
||||
static int _csync_journal_is_empty(CSYNC *ctx) {
|
||||
c_strlist_t *result = NULL;
|
||||
int rc = 0;
|
||||
|
||||
|
@ -93,7 +93,7 @@ int csync_journal_load(CSYNC *ctx, const char *journal) {
|
|||
c_strlist_t *result = NULL;
|
||||
char *journal_tmp = NULL;
|
||||
|
||||
if (csync_journal_check(journal) < 0) {
|
||||
if (_csync_journal_check(journal) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ int csync_journal_load(CSYNC *ctx, const char *journal) {
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (csync_journal_is_empty(ctx)) {
|
||||
if (_csync_journal_is_empty(ctx)) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "Journal doesn't exist");
|
||||
ctx->journal.exists = 0;
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.lock"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int csync_lock_create(const char *lockfile) {
|
||||
static int _csync_lock_create(const char *lockfile) {
|
||||
int fd, pid, rc = -1;
|
||||
char *ctmpfile = NULL;
|
||||
char *dir = NULL;
|
||||
|
@ -93,7 +93,7 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static pid_t csync_lock_read(const char *lockfile) {
|
||||
static pid_t _csync_lock_read(const char *lockfile) {
|
||||
char buf[8] = {0};
|
||||
int fd, pid;
|
||||
|
||||
|
@ -133,19 +133,19 @@ static pid_t csync_lock_read(const char *lockfile) {
|
|||
|
||||
int csync_lock(const char *lockfile) {
|
||||
/* Check if lock already exists. */
|
||||
if (csync_lock_read(lockfile) > 0) {
|
||||
if (_csync_lock_read(lockfile) > 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Aborting, another synchronization process is running.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "Creating lock file: %s", lockfile);
|
||||
|
||||
return csync_lock_create(lockfile);
|
||||
return _csync_lock_create(lockfile);
|
||||
}
|
||||
|
||||
void csync_lock_remove(const char *lockfile) {
|
||||
/* You can't remove the lock if it is from another process */
|
||||
if (csync_lock_read(lockfile) == getpid()) {
|
||||
if (_csync_lock_read(lockfile) == getpid()) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Removing lock file: %s", lockfile);
|
||||
if (unlink(lockfile) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Unable to remove lock %s - %s", lockfile, strerror(errno));
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.reconciler"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int csync_merge_algorithm_visitor(void *obj, void *data) {
|
||||
static int _csync_merge_algorithm_visitor(void *obj, void *data) {
|
||||
csync_file_stat_t *cur = NULL;
|
||||
csync_file_stat_t *other = NULL;
|
||||
CSYNC *ctx = NULL;
|
||||
|
@ -162,7 +162,7 @@ int csync_reconcile_updates(CSYNC *ctx) {
|
|||
break;
|
||||
}
|
||||
|
||||
rc = c_rbtree_walk(tree, (void *) ctx, csync_merge_algorithm_visitor);
|
||||
rc = c_rbtree_walk(tree, (void *) ctx, _csync_merge_algorithm_visitor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define CSYNC_LOG_CATEGORY_NAME "csync.updater"
|
||||
#include "csync_log.h"
|
||||
|
||||
static int csync_detect_update(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, const int type) {
|
||||
static int _csync_detect_update(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, const int type) {
|
||||
time_t modtime = 0;
|
||||
uint64_t h = 0;
|
||||
size_t len = 0;
|
||||
|
@ -165,7 +165,7 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
|
|||
case CSYNC_FTW_FLAG_FILE:
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s", file);
|
||||
|
||||
return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE);
|
||||
return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE);
|
||||
break;
|
||||
case CSYNC_FTW_FLAG_SLINK:
|
||||
/* FIXME: implement support for symlinks, see csync_propagate.c too */
|
||||
|
@ -173,14 +173,14 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
|
|||
if (ctx->options.sync_symbolic_links) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "symlink: %s", file);
|
||||
|
||||
return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_SLINK);
|
||||
return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_SLINK);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case CSYNC_FTW_FLAG_DIR: /* enter directory */
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s", file);
|
||||
|
||||
return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_DIR);
|
||||
return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_DIR);
|
||||
case CSYNC_FTW_FLAG_NSTAT: /* not statable file */
|
||||
case CSYNC_FTW_FLAG_DNR:
|
||||
case CSYNC_FTW_FLAG_DP:
|
||||
|
|
|
@ -374,7 +374,7 @@ c_list_t *c_list_find_custom(c_list_t *list, void *data, c_list_compare_fn func)
|
|||
/*
|
||||
* Internal used function to merge 2 lists using a compare function
|
||||
*/
|
||||
static c_list_t *c_list_merge(c_list_t *list1, c_list_t *list2, c_list_compare_fn func) {
|
||||
static c_list_t *_c_list_merge(c_list_t *list1, c_list_t *list2, c_list_compare_fn func) {
|
||||
int cmp;
|
||||
|
||||
/* lists are emty */
|
||||
|
@ -387,12 +387,12 @@ static c_list_t *c_list_merge(c_list_t *list1, c_list_t *list2, c_list_compare_f
|
|||
cmp = ((c_list_compare_fn) func)(list1->data, list2->data);
|
||||
/* compare if it is smaller */
|
||||
if (cmp <= 0) {
|
||||
list1->next = c_list_merge(list1->next, list2, func);
|
||||
list1->next = _c_list_merge(list1->next, list2, func);
|
||||
if (list1->next) {
|
||||
list1->next->prev = list1;
|
||||
}return list1;
|
||||
} else {
|
||||
list2->next = c_list_merge(list1, list2->next, func);
|
||||
list2->next = _c_list_merge(list1, list2->next, func);
|
||||
if (list2->next) {
|
||||
list2->next->prev = list2;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ static c_list_t *c_list_merge(c_list_t *list1, c_list_t *list2, c_list_compare_f
|
|||
/*
|
||||
* Internally used function to split 2 lists.
|
||||
*/
|
||||
static c_list_t *c_list_split(c_list_t *list) {
|
||||
static c_list_t *_c_list_split(c_list_t *list) {
|
||||
c_list_t *second = NULL;
|
||||
|
||||
/* list is empty */
|
||||
|
@ -422,7 +422,7 @@ static c_list_t *c_list_split(c_list_t *list) {
|
|||
}
|
||||
|
||||
second->prev = NULL;
|
||||
second->next = c_list_split(second->next);
|
||||
second->next = _c_list_split(second->next);
|
||||
/* is last element */
|
||||
if (second->next) {
|
||||
second->next->prev = second;
|
||||
|
@ -445,9 +445,9 @@ c_list_t *c_list_sort(c_list_t *list, c_list_compare_fn func) {
|
|||
return list;
|
||||
} else {
|
||||
/* split list */
|
||||
second = c_list_split(list);
|
||||
second = _c_list_split(list);
|
||||
}
|
||||
|
||||
return c_list_merge(c_list_sort(list, func), c_list_sort(second, func), func);
|
||||
return _c_list_merge(c_list_sort(list, func), c_list_sort(second, func), func);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ int c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_r
|
|||
return 0;
|
||||
}
|
||||
|
||||
static c_rbnode_t *c_rbtree_subtree_dup(const c_rbnode_t *node, c_rbtree_t *new_tree, c_rbnode_t *new_parent) {
|
||||
static c_rbnode_t *_rbtree_subtree_dup(const c_rbnode_t *node, c_rbtree_t *new_tree, c_rbnode_t *new_parent) {
|
||||
c_rbnode_t *new_node = NULL;
|
||||
|
||||
new_node = (c_rbnode_t*) c_malloc(sizeof(c_rbnode_t));
|
||||
|
@ -74,13 +74,13 @@ static c_rbnode_t *c_rbtree_subtree_dup(const c_rbnode_t *node, c_rbtree_t *new_
|
|||
if (node->left == NIL) {
|
||||
new_node->left = NIL;
|
||||
} else {
|
||||
new_node->left = c_rbtree_subtree_dup(node->left, new_tree, new_node);
|
||||
new_node->left = _rbtree_subtree_dup(node->left, new_tree, new_node);
|
||||
}
|
||||
|
||||
if (node->right == NIL) {
|
||||
new_node->right = NIL;
|
||||
} else {
|
||||
new_node->right = c_rbtree_subtree_dup(node->right, new_tree, new_node);
|
||||
new_node->right = _rbtree_subtree_dup(node->right, new_tree, new_node);
|
||||
}
|
||||
|
||||
return new_node;
|
||||
|
@ -94,23 +94,23 @@ c_rbtree_t *c_rbtree_dup(const c_rbtree_t *tree) {
|
|||
new_tree->key_compare = tree->key_compare;
|
||||
new_tree->data_compare = tree->data_compare;
|
||||
new_tree->size = tree->size;
|
||||
new_tree->root = c_rbtree_subtree_dup(tree->root, new_tree, NULL);
|
||||
new_tree->root = _rbtree_subtree_dup(tree->root, new_tree, NULL);
|
||||
|
||||
return new_tree;
|
||||
}
|
||||
|
||||
static int c_rbtree_subtree_free(c_rbnode_t *node) {
|
||||
static int _rbtree_subtree_free(c_rbnode_t *node) {
|
||||
assert(node);
|
||||
|
||||
if (node->left != NIL) {
|
||||
if (c_rbtree_subtree_free(node->left) < 0) {
|
||||
if (_rbtree_subtree_free(node->left) < 0) {
|
||||
/* TODO: set errno? ECANCELED? */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->right != NIL) {
|
||||
if (c_rbtree_subtree_free(node->right) < 0) {
|
||||
if (_rbtree_subtree_free(node->right) < 0) {
|
||||
/* TODO: set errno? ECANCELED? */
|
||||
return -1;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ int c_rbtree_free(c_rbtree_t *tree) {
|
|||
}
|
||||
|
||||
if (tree->root != NIL) {
|
||||
c_rbtree_subtree_free(tree->root);
|
||||
_rbtree_subtree_free(tree->root);
|
||||
}
|
||||
|
||||
SAFE_FREE(tree);
|
||||
|
@ -136,7 +136,7 @@ int c_rbtree_free(c_rbtree_t *tree) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int c_rbtree_subtree_walk(c_rbnode_t *node, void *data, c_rbtree_visit_func *visitor) {
|
||||
static int _rbtree_subtree_walk(c_rbnode_t *node, void *data, c_rbtree_visit_func *visitor) {
|
||||
assert(node);
|
||||
assert(data);
|
||||
assert(visitor);
|
||||
|
@ -145,7 +145,7 @@ static int c_rbtree_subtree_walk(c_rbnode_t *node, void *data, c_rbtree_visit_fu
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (c_rbtree_subtree_walk(node->left, data, visitor) < 0) {
|
||||
if (_rbtree_subtree_walk(node->left, data, visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ static int c_rbtree_subtree_walk(c_rbnode_t *node, void *data, c_rbtree_visit_fu
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (c_rbtree_subtree_walk(node->right, data, visitor) < 0) {
|
||||
if (_rbtree_subtree_walk(node->right, data, visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -166,14 +166,14 @@ int c_rbtree_walk(c_rbtree_t *tree, void *data, c_rbtree_visit_func *visitor) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (c_rbtree_subtree_walk(tree->root, data, visitor) < 0) {
|
||||
if (_rbtree_subtree_walk(tree->root, data, visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static c_rbnode_t *c_rbtree_subtree_head(c_rbnode_t *node) {
|
||||
static c_rbnode_t *_rbtree_subtree_head(c_rbnode_t *node) {
|
||||
assert(node);
|
||||
|
||||
if (node == NIL) {
|
||||
|
@ -187,7 +187,7 @@ static c_rbnode_t *c_rbtree_subtree_head(c_rbnode_t *node) {
|
|||
return node;
|
||||
}
|
||||
|
||||
static c_rbnode_t *c_rbtree_subtree_tail(c_rbnode_t *node) {
|
||||
static c_rbnode_t *_rbtree_subtree_tail(c_rbnode_t *node) {
|
||||
assert(node);
|
||||
|
||||
if (node == NIL) {
|
||||
|
@ -209,7 +209,7 @@ c_rbnode_t *c_rbtree_head(c_rbtree_t *tree) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
node = c_rbtree_subtree_head(tree->root);
|
||||
node = _rbtree_subtree_head(tree->root);
|
||||
|
||||
return node != NIL ? node : NULL;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ c_rbnode_t *c_rbtree_tail(c_rbtree_t *tree) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
node = c_rbtree_subtree_tail(tree->root);
|
||||
node = _rbtree_subtree_tail(tree->root);
|
||||
|
||||
return node != NIL ? node : NULL;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ c_rbnode_t *c_rbtree_node_next(c_rbnode_t *node) {
|
|||
|
||||
if (node->right != NIL) {
|
||||
c_rbnode_t *next = NULL;
|
||||
next = c_rbtree_subtree_head(node->right);
|
||||
next = _rbtree_subtree_head(node->right);
|
||||
|
||||
return next != NIL ? next : NULL;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ c_rbnode_t *c_rbtree_node_prev(c_rbnode_t *node) {
|
|||
|
||||
if (node->left != NIL) {
|
||||
c_rbnode_t *prev = NULL;
|
||||
prev = c_rbtree_subtree_tail(node->left);
|
||||
prev = _rbtree_subtree_tail(node->left);
|
||||
return prev != NIL ? prev : NULL;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ c_rbnode_t *c_rbtree_find(c_rbtree_t *tree, const void *key) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void c_rbtree_subtree_left_rotate(c_rbnode_t *x) {
|
||||
static void _rbtree_subtree_left_rotate(c_rbnode_t *x) {
|
||||
c_rbnode_t *y = NULL;
|
||||
|
||||
assert(x);
|
||||
|
@ -336,7 +336,7 @@ static void c_rbtree_subtree_left_rotate(c_rbnode_t *x) {
|
|||
}
|
||||
|
||||
/* rotat node x to the right */
|
||||
static void c_rbtree_subtree_right_rotate(c_rbnode_t *x) {
|
||||
static void _rbtree_subtree_right_rotate(c_rbnode_t *x) {
|
||||
c_rbnode_t *y = NULL;
|
||||
|
||||
assert(x);
|
||||
|
@ -442,11 +442,11 @@ int c_rbtree_insert(c_rbtree_t *tree, void *data) {
|
|||
if (x == x->parent->right) {
|
||||
/* make x a left child */
|
||||
x = x->parent;
|
||||
c_rbtree_subtree_left_rotate(x);
|
||||
_rbtree_subtree_left_rotate(x);
|
||||
}
|
||||
x->parent->color = BLACK;
|
||||
x->parent->parent->color = RED;
|
||||
c_rbtree_subtree_right_rotate(x->parent->parent);
|
||||
_rbtree_subtree_right_rotate(x->parent->parent);
|
||||
}
|
||||
} else {
|
||||
c_rbnode_t *y = NULL;
|
||||
|
@ -461,11 +461,11 @@ int c_rbtree_insert(c_rbtree_t *tree, void *data) {
|
|||
/* uncle is back */
|
||||
if (x == x->parent->left) {
|
||||
x = x->parent;
|
||||
c_rbtree_subtree_right_rotate(x);
|
||||
_rbtree_subtree_right_rotate(x);
|
||||
}
|
||||
x->parent->color = BLACK;
|
||||
x->parent->parent->color = RED;
|
||||
c_rbtree_subtree_left_rotate(x->parent->parent);
|
||||
_rbtree_subtree_left_rotate(x->parent->parent);
|
||||
}
|
||||
}
|
||||
} /* end while */
|
||||
|
@ -559,7 +559,7 @@ int c_rbtree_node_delete(c_rbnode_t *node) {
|
|||
if (w->color == RED) {
|
||||
w->color = BLACK;
|
||||
x->parent->color = RED;
|
||||
c_rbtree_subtree_left_rotate(x->parent);
|
||||
_rbtree_subtree_left_rotate(x->parent);
|
||||
w = x->parent->right;
|
||||
}
|
||||
|
||||
|
@ -570,13 +570,13 @@ int c_rbtree_node_delete(c_rbnode_t *node) {
|
|||
if (w->right->color == BLACK) {
|
||||
w->left->color = BLACK;
|
||||
w->color = RED;
|
||||
c_rbtree_subtree_right_rotate(w);
|
||||
_rbtree_subtree_right_rotate(w);
|
||||
w = x->parent->right;
|
||||
}
|
||||
w->color = x->parent->color;
|
||||
x->parent->color = BLACK;
|
||||
w->right->color = BLACK;
|
||||
c_rbtree_subtree_left_rotate(x->parent);
|
||||
_rbtree_subtree_left_rotate(x->parent);
|
||||
x = y->tree->root;
|
||||
}
|
||||
} else {
|
||||
|
@ -586,7 +586,7 @@ int c_rbtree_node_delete(c_rbnode_t *node) {
|
|||
if (w->color == RED) {
|
||||
w->color = BLACK;
|
||||
x->parent->color = RED;
|
||||
c_rbtree_subtree_right_rotate(x->parent);
|
||||
_rbtree_subtree_right_rotate(x->parent);
|
||||
w = x->parent->left;
|
||||
}
|
||||
|
||||
|
@ -597,13 +597,13 @@ int c_rbtree_node_delete(c_rbnode_t *node) {
|
|||
if (w->left->color == BLACK) {
|
||||
w->right->color = BLACK;
|
||||
w->color = RED;
|
||||
c_rbtree_subtree_left_rotate(w);
|
||||
_rbtree_subtree_left_rotate(w);
|
||||
w = x->parent->left;
|
||||
}
|
||||
w->color = x->parent->color;
|
||||
x->parent->color = BLACK;
|
||||
w->left->color = BLACK;
|
||||
c_rbtree_subtree_right_rotate(x->parent);
|
||||
_rbtree_subtree_right_rotate(x->parent);
|
||||
x = y->tree->root;
|
||||
}
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ int c_rbtree_node_delete(c_rbnode_t *node) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int c_rbtree_subtree_check_black_height(c_rbnode_t *node) {
|
||||
static int _rbtree_subtree_check_black_height(c_rbnode_t *node) {
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
|
||||
|
@ -628,8 +628,8 @@ static int c_rbtree_subtree_check_black_height(c_rbnode_t *node) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
left = c_rbtree_subtree_check_black_height(node->left);
|
||||
right = c_rbtree_subtree_check_black_height(node->right);
|
||||
left = _rbtree_subtree_check_black_height(node->left);
|
||||
right = _rbtree_subtree_check_black_height(node->right);
|
||||
if (left != right) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ int c_rbtree_check_sanity(c_rbtree_t *tree) {
|
|||
return -18;
|
||||
}
|
||||
|
||||
if (c_rbtree_subtree_check_black_height(tree->root) < 0) {
|
||||
if (_rbtree_subtree_check_black_height(tree->root) < 0) {
|
||||
return -19;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ static void teardown(void) {
|
|||
|
||||
START_TEST (check_csync_config_copy_default)
|
||||
{
|
||||
fail_unless(csync_config_copy_default(testconf) == 0, NULL);
|
||||
fail_unless(_csync_config_copy_default(testconf) == 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static void teardown(void) {
|
|||
|
||||
START_TEST (check_csync_exclude_add)
|
||||
{
|
||||
csync_exclude_add(csync, (const char *) "/tmp/check_csync1/*");
|
||||
_csync_exclude_add(csync, (const char *) "/tmp/check_csync1/*");
|
||||
fail_unless(strcmp(csync->excludes->vector[0], (const char *) "/tmp/check_csync1/*") == 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
@ -30,16 +30,16 @@ START_TEST (check_csync_journal_check)
|
|||
|
||||
/* old db */
|
||||
fail_if(system("echo \"SQLite format 2\" > /tmp/check_csync1/test.db") < 0, NULL);
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
fail_unless(_csync_journal_check(testdb) == 0);
|
||||
|
||||
/* db already exists */
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
fail_unless(_csync_journal_check(testdb) == 0);
|
||||
|
||||
/* no db exists */
|
||||
fail_if(system("rm -f /tmp/check_csync1/test.db") < 0, NULL);
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
fail_unless(_csync_journal_check(testdb) == 0);
|
||||
|
||||
fail_unless(csync_journal_check((char *) "/tmp/check_csync1/") < 0);
|
||||
fail_unless(_csync_journal_check((char *) "/tmp/check_csync1/") < 0);
|
||||
|
||||
fail_if(system("rm -rf /tmp/check_csync1") < 0, NULL);
|
||||
}
|
||||
|
|
|
@ -112,14 +112,14 @@ START_TEST (check_csync_journal_is_empty)
|
|||
c_strlist_t *result = NULL;
|
||||
|
||||
/* we have an empty db */
|
||||
fail_unless(csync_journal_is_empty(csync) == 1, NULL);
|
||||
fail_unless(_csync_journal_is_empty(csync) == 1, NULL);
|
||||
|
||||
/* add a table and an entry */
|
||||
result = csync_journal_query(csync, "CREATE TABLE metadata(phash INTEGER, text VARCHAR(10));");
|
||||
c_strlist_destroy(result);
|
||||
fail_unless(csync_journal_insert(csync, "INSERT INTO metadata (phash, text) VALUES (42, 'hello');"), NULL);
|
||||
|
||||
fail_unless(csync_journal_is_empty(csync) == 0, NULL);
|
||||
fail_unless(_csync_journal_is_empty(csync) == 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
Loading…
Reference in a new issue