* Entry point. */
| 116 | * Entry point. |
| 117 | */ |
| 118 | void entry(const void *bb, const void *next) |
| 119 | { |
| 120 | uintptr_t to = (uintptr_t)next; |
| 121 | uintptr_t from = (uintptr_t)bb; |
| 122 | to = bb_lookup(to); |
| 123 | ENTRY key = {from, to, 0}; |
| 124 | |
| 125 | if (!LOCK()) |
| 126 | return; |
| 127 | |
| 128 | void *node = tfind(&key, &COV, compare); |
| 129 | ENTRY *entry = (node != NULL? *(ENTRY **)node: NULL); |
| 130 | if (entry == NULL) |
| 131 | { |
| 132 | entry = (ENTRY *)malloc(sizeof(ENTRY)); |
| 133 | if (entry == NULL) |
| 134 | error("failed to allocate memory: %s", strerror(errno)); |
| 135 | memcpy(entry, &key, sizeof(ENTRY)); |
| 136 | (void)tsearch(entry, &COV, compare); |
| 137 | } |
| 138 | entry->count++; |
| 139 | |
| 140 | UNLOCK(); |
| 141 | } |
| 142 | |
| 143 | /* |
| 144 | * Init. |