ib_hash_entry_t *ib_hash_find_htentry( const ib_hash_t *hash, ib_hash_entry_t *first, const void *key, size_t key_length, uint32_t hash_value ) { IB_FTRACE_INIT(); assert(hash != NULL); assert(key != NULL); for ( ib_hash_entry_t* current_entry = first; current_entry != NULL; current_entry = current_entry->next_entry ) { if ( current_entry->hash_value == hash_value && hash->equal_predicate( key, key_length, current_entry->key, current_entry->key_length ) ) { IB_FTRACE_RET_PTR(ib_hash_entry_t, current_entry); } } IB_FTRACE_RET_PTR(ib_hash_entry_t, NULL); }
uint8_t *ib_bytestr_ptr( ib_bytestr_t *bs ) { IB_FTRACE_INIT(); if (bs == NULL || IB_BYTESTR_CHECK_FREADONLY(bs->flags)) { IB_FTRACE_RET_PTR(uint8_t, NULL); } IB_FTRACE_RET_PTR(uint8_t, bs->data); }
ib_provider_inst_t *ib_log_provider_get_instance(ib_context_t *ctx) { IB_FTRACE_INIT(); ib_core_cfg_t *corecfg; ib_status_t rc; rc = ib_context_module_config(ctx, ib_core_module(), (void *)&corecfg); if (rc != IB_OK) { IB_FTRACE_RET_PTR(ib_provider_inst_t, NULL); } IB_FTRACE_RET_PTR(ib_provider_inst_t, corecfg->pi.logger); }
/** * Search the state to go to for the given state and letter. It represents * the goto() function of aho corasick using a balanced binary tree for * fast searching * * @param state the parent state * @param letter the ascii code to search * * @return ib_ac_state_t pointer to the state if found or NULL */ static inline ib_ac_state_t *ib_ac_bintree_goto(ib_ac_state_t *state, ib_ac_char_t letter) { IB_FTRACE_INIT(); ib_ac_bintree_t *bin_state = NULL; if (state == NULL) { IB_FTRACE_RET_PTR(ib_ac_state_t, NULL); } for (bin_state = state->bintree; bin_state != NULL; bin_state = (bin_state->letter > letter) ? bin_state->left : bin_state->right ) { if (bin_state->letter == letter) { IB_FTRACE_RET_PTR(ib_ac_state_t, bin_state->state); } } IB_FTRACE_RET_PTR(ib_ac_state_t, NULL); }
/** * Returns the state that would result of applying the * aho corasick goto() function to a given state with the given letter * * @param parent_state the state from which the transition would be done * @param char_state the letter used for the transition * * @returns the state in result */ static ib_ac_state_t* ib_ac_child_for_code(ib_ac_state_t *parent_state, ib_ac_char_t char_state) { IB_FTRACE_INIT(); ib_ac_state_t *state = NULL; if (parent_state == NULL || parent_state->child == NULL) { IB_FTRACE_RET_PTR(ib_ac_state_t, NULL); } for (state = parent_state->child; state != NULL; state = state->sibling) { if (state->letter == char_state) { IB_FTRACE_RET_PTR(ib_ac_state_t, state); } } IB_FTRACE_RET_PTR(ib_ac_state_t, NULL); }
ib_list_node_t *ib_list_node_prev(ib_list_node_t *node) { IB_FTRACE_INIT(ib_list_node_prev); IB_FTRACE_RET_PTR(ib_list_node_t, IB_LIST_NODE_PREV(node)); }
ib_list_node_t *ib_list_node_next(ib_list_node_t *node) { IB_FTRACE_INIT(ib_list_node_next); IB_FTRACE_RET_PTR(ib_list_node_t, IB_LIST_NODE_NEXT(node)); }
ib_list_node_t *ib_list_last(ib_list_t *list) { IB_FTRACE_INIT(ib_list_last); IB_FTRACE_RET_PTR(ib_list_node_t, IB_LIST_LAST(list)); }
ib_list_node_t *ib_list_first(ib_list_t *list) { IB_FTRACE_INIT(ib_list_first); IB_FTRACE_RET_PTR(ib_list_node_t, IB_LIST_FIRST(list)); }
ib_mpool_t* ib_bytestr_mpool(const ib_bytestr_t *bs) { IB_FTRACE_INIT(); IB_FTRACE_RET_PTR(ib_mpool_t, bs->mp); }