Fix minor mem leak in test case
[platform/upstream/glib.git] / gio / kqueue / dep-list.h
1 /*******************************************************************************
2   Copyright (c) 2011, 2012 Dmitry Matveev <me@dmitrymatveev.co.uk>
3
4   Permission is hereby granted, free of charge, to any person obtaining a copy
5   of this software and associated documentation files (the "Software"), to deal
6   in the Software without restriction, including without limitation the rights
7   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8   copies of the Software, and to permit persons to whom the Software is
9   furnished to do so, subject to the following conditions:
10
11   The above copyright notice and this permission notice shall be included in
12   all copies or substantial portions of the Software.
13
14   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   THE SOFTWARE.
21 *******************************************************************************/
22
23 #ifndef __DEP_LIST_H__
24 #define __DEP_LIST_H__
25
26 #include <sys/types.h> /* ino_t */
27
28 typedef struct dep_list {
29     struct dep_list *next;
30
31     char *path;
32     ino_t inode;
33 } dep_list;
34
35 typedef void (* no_entry_cb)     (void *udata);
36 typedef void (* single_entry_cb) (void *udata, const char *path, ino_t inode);
37 typedef void (* dual_entry_cb)   (void *udata,
38                                   const char *from_path, ino_t from_inode,
39                                   const char *to_path,   ino_t to_inode);
40 typedef void (* list_cb)         (void *udata, const dep_list *list);
41
42
43 typedef struct traverse_cbs {
44     single_entry_cb  added;
45     single_entry_cb  removed;
46     dual_entry_cb    replaced;
47     single_entry_cb  overwritten;
48     dual_entry_cb    moved;
49     list_cb          many_added;
50     list_cb          many_removed;
51     no_entry_cb      names_updated;
52 } traverse_cbs;
53
54 dep_list* dl_create       (char *path, ino_t inode);
55 void      dl_print        (const dep_list *dl);
56 dep_list* dl_shallow_copy (const dep_list *dl);
57 void      dl_shallow_free (dep_list *dl);
58 void      dl_free         (dep_list *dl);
59 dep_list* dl_listing      (const char *path);
60 void      dl_diff         (dep_list **before, dep_list **after);
61
62 void
63 dl_calculate (dep_list            *before,
64               dep_list            *after,
65               const traverse_cbs  *cbs,
66               void                *udata);
67
68
69 #endif /* __DEP_LIST_H__ */