static struct InterfaceInfo * find_interface(const char *name) { struct InterfaceInfo tmp_info = { name }; struct RBNode *node = rbSearch(interface_tree, &tmp_info); if(node == NULL) return NULL; return to_interface(node); }
//find class in rb_tree by class name static struct ZObjClass * find_class(const char *name) { struct ZObjClass tmp_class = { name }; struct RBNode *node = rbSearch(class_tree, &tmp_class); if(node == NULL) return NULL; return to_class(node); }
struct ZObjInstance * __get_cur_error() { unsigned long thread_id = cur_thread; spinLock(&spin_lk); struct RBNode *stack = rbSearch(stack_tree, &thread_id); spinUnlock(&spin_lk); assert(to_stack(stack)->cur_error != NULL); return to_stack(stack)->cur_error; }
void __throw(struct ZObjInstance *e) { unsigned long thread_id = cur_thread; spinLock(&spin_lk); struct RBNode *stack = rbSearch(stack_tree, &thread_id); spinUnlock(&spin_lk); to_stack(stack)->cur_error = e; longjmp(to_stack(stack)->stack_top->jb, 1); }
void __pop_jmp_point() { unsigned long thread_id = cur_thread; spinLock(&spin_lk); struct RBNode *stack = rbSearch(stack_tree, &thread_id); spinUnlock(&spin_lk); struct stack_node *node = to_stack(stack)->stack_top; assert(node != NULL); to_stack(stack)->stack_top = node->prev; free(node); }
void * __push_jmp_point() { unsigned long thread_id = cur_thread; spinLock(&spin_lk); rbInsert(&stack_tree, &thread_id); spinUnlock(&spin_lk); struct RBNode *stack = rbSearch(stack_tree, &thread_id); struct stack_node *new_node = malloc(sizeof(struct stack_node)); assert(new_node != NULL); new_node->prev = to_stack(stack)->stack_top; to_stack(stack)->stack_top = new_node; return new_node->jb; }
int main(int argc, char **argv){ RBTree T = NULL; Node *x; int i = 0; for (i = 1; i <= 20; i++) rbInsert(&T, i); // rbInsert(&T,80); // rbInsert(&T,90); // rbInsert(&T,40); // rbDelete(&T,rbSearch(T,130)); // rbDelete(&T,rbSearch(T,90)); rbPrint(T); printf("max=%d\n", rbMaxKey(T)->key); printf("min=%d\n", rbMinKey(T)->key); printf("search=%d\n", rbSearch(T, 16)->key); return 0; }