Archived
1
0
Fork 0

common/rbtree: fixed a bug in delete

This commit is contained in:
Henrik Hautakoski 2010-10-02 08:20:48 +02:00
parent 8d7b4a74c7
commit 7209cfb1c4
7 changed files with 52 additions and 37 deletions

View file

@ -42,16 +42,17 @@ static queue_t event_queue;
static int addwatch(const char *path, const char *name) {
rbnode *node;
char *cpath;
char *npath;
int wd;
cpath = path_normalize(path, name, 1);
npath = path_normalize(path, name, 1);
wd = inotify_add_watch(fd, cpath, WATCH_MASK);
wd = inotify_add_watch(fd, npath, WATCH_MASK);
if (wd < 0) {
perror("NOTIFY ADD");
dprint("%i path %s\n", errno == EBADF, cpath);
dprint("%i path %s\n", errno == EBADF, npath);
free(npath);
return -errno;
}
@ -59,12 +60,13 @@ static int addwatch(const char *path, const char *name) {
node = rbtree_search(&tree, wd);
if (node == NULL) {
dprint("added wd = %i on %s\n", wd, cpath);
rbtree_insert(&tree, wd, (void*)cpath);
dprint("added wd = %i on %s\n", wd, npath);
rbtree_insert(&tree, wd, (void*)npath, strlen(npath)+1);
} else {
dprint("updated wd = %i from %s to %s\n", wd, (char*)node->data, cpath);
dprint("updated wd = %i from %s to %s\n", wd, (char*)node->data, npath);
free(node->data);
node->data = (void*) cpath;
node->data = (void*) npath;
node->len = strlen(npath)+1;
}
return wd;