- Timestamp:
- Oct 21, 2011, 1:08:28 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/sh_inotify.h
r261 r363 6 6 typedef struct 7 7 { 8 /* 9 void * list_of_watches; 10 */ 11 8 12 int watch[SH_INOTIFY_MAX]; 9 13 int flag[SH_INOTIFY_MAX]; 10 14 char * file[SH_INOTIFY_MAX]; 11 int count;12 15 16 int count; 17 int max_count; 13 18 } sh_watches; 19 20 #define SH_INOTIFY_INITIALIZER { { 0 }, { 0 }, { NULL}, 0, 0 } 14 21 15 22 int sh_inotify_wait_for_change(char * filename, sh_watches * watches, -
trunk/include/zAVLTree.h
r1 r363 33 33 34 34 /* typedef the keytype */ 35 typedef const char* zAVLKey;35 typedef const void * zAVLKey; 36 36 37 37 /* Comparison function for strings is strcmp(). */ 38 #define zAVLKey_cmp(tree, a, b) (strcmp((a), (b))) 38 /* #define zAVLKey_cmp(tree, a, b) (strcmp((a), (b))) */ 39 40 #define zAVL_KEY_STRING 0 41 #define zAVL_KEY_INT 1 39 42 40 43 … … 53 56 long count; 54 57 zAVLKey (*getkey)(const void *item); 58 int keytype; 55 59 } zAVLTree; 56 60 … … 62 66 63 67 64 extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item) );68 extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype); 65 69 extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item)); 66 70 extern int zAVLInsert (zAVLTree *avltree, void *item); -
trunk/src/cutest_zAVLTree.c
r17 r363 44 44 CuAssertTrue(tc, NULL == ptr); 45 45 46 ztest_tree = zAVLAllocTree (ztest_key );46 ztest_tree = zAVLAllocTree (ztest_key, zAVL_KEY_STRING); 47 47 CuAssertPtrNotNull(tc, ztest_tree); 48 48 -
trunk/src/sh_files.c
r362 r363 897 897 if (zfileList == NULL) 898 898 { 899 zfileList = zAVLAllocTree (zdirstack_key );899 zfileList = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING); 900 900 if (zfileList == NULL) 901 901 { … … 975 975 if (zglobList == NULL) 976 976 { 977 zglobList = zAVLAllocTree (zdirstack_key );977 zglobList = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING); 978 978 if (zglobList == NULL) 979 979 { … … 1456 1456 if (tree == NULL) 1457 1457 { 1458 tree = zAVLAllocTree (zdirstack_key );1458 tree = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING); 1459 1459 if (tree == NULL) 1460 1460 { -
trunk/src/sh_forward.c
r342 r363 2088 2088 if (all_clients == NULL) 2089 2089 { 2090 all_clients = zAVLAllocTree (sh_avl_key );2090 all_clients = zAVLAllocTree (sh_avl_key, zAVL_KEY_STRING); 2091 2091 if (all_clients == NULL) 2092 2092 { -
trunk/src/sh_log_evalrule.c
r357 r363 1122 1122 { 1123 1123 DEBUG("debug: allocate new counterlist AVL tree\n"); 1124 rule->counterlist = zAVLAllocTree(sh_eval_getkey );1124 rule->counterlist = zAVLAllocTree(sh_eval_getkey, zAVL_KEY_STRING); 1125 1125 } 1126 1126 -
trunk/src/sh_log_mark.c
r272 r363 77 77 if (!(marklist)) 78 78 { 79 marklist = zAVLAllocTree(sh_log_mark_getkey );79 marklist = zAVLAllocTree(sh_log_mark_getkey, zAVL_KEY_STRING); 80 80 } 81 81 -
trunk/src/sh_nmail.c
r304 r363 957 957 } 958 958 959 mailkeys = zAVLAllocTree (sh_nmail_getkey );959 mailkeys = zAVLAllocTree (sh_nmail_getkey, zAVL_KEY_STRING); 960 960 goto start; 961 961 } -
trunk/src/sh_utmp.c
r332 r363 558 558 559 559 #if defined(HAVE_PTHREAD) 560 static sh_watches inotify_watch ;560 static sh_watches inotify_watch = SH_INOTIFY_INITIALIZER; 561 561 #endif 562 562 -
trunk/src/zAVLTree.c
r16 r363 53 53 #define ZAVL_NO 0 54 54 55 /* The comparison function. Was a macro, but this allows for more 56 * flexibility (non-string keys). The key is a (void *) now, and 57 * the type is stored in the zAVLTree struct. Oct 21, 2011, rw 58 */ 59 static int zAVLKey_cmp(const zAVLTree * tree, zAVLKey a, zAVLKey b) 60 { 61 if (tree->keytype == zAVL_KEY_STRING) 62 { 63 return (strcmp((char*)a, (char *)b)); 64 } 65 else /* zAVL_KEY_INT */ 66 { 67 int x = *((int *)a); 68 int y = *((int *)b); 69 70 if (x > y) return 1; 71 else if (x < y) return -1; 72 else return 0; 73 } 74 } 55 75 56 76 /* … … 62 82 * was a malloc failure, then NULL is returned. 63 83 */ 64 zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item) )84 zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype) 65 85 { 66 86 zAVLTree *rc; … … 73 93 rc->count = 0; 74 94 rc->getkey = getkey; 95 rc->keytype = keytype; 75 96 return rc; 76 97 }
Note:
See TracChangeset
for help on using the changeset viewer.