void node_add (struct node * root, char * string) { if (string_compare (root->data, string) == -1) { if (root->left == NULL) { struct node * t = node_allocate (); t->data = strdup (string); root->left = t; } else node_add (root->left, string); } else { if (root->right == NULL) { struct node * t = node_allocate (); t->data = strdup (string); root->right = t; } else node_add (root->right, string); } }
u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt) { int status = 0; struct dsp_uuid node_uuid; u32 cb_data_size = 0; u32 __user *psize = (u32 __user *) args->args_node_allocate.args; u8 *pargs = NULL; struct dsp_nodeattrin proc_attr_in, *attr_in = NULL; struct node_res_object *node_res; int nodeid; void *hprocessor = ((struct process_context *)pr_ctxt)->processor; if (psize) { if (get_user(cb_data_size, psize)) status = -EPERM; cb_data_size += sizeof(u32); if (!status) { pargs = kmalloc(cb_data_size, GFP_KERNEL); if (pargs == NULL) status = -ENOMEM; } CP_FM_USR(pargs, args->args_node_allocate.args, status, cb_data_size); } CP_FM_USR(&node_uuid, args->args_node_allocate.node_id_ptr, status, 1); if (status) goto func_cont; if (args->args_node_allocate.attr_in) { CP_FM_USR(&proc_attr_in, args->args_node_allocate.attr_in, status, 1); if (!status) attr_in = &proc_attr_in; else status = -ENOMEM; } if (!status) { status = node_allocate(hprocessor, &node_uuid, (struct dsp_cbdata *)pargs, attr_in, &node_res, pr_ctxt); } if (!status) { nodeid = node_res->id + 1; CP_TO_USR(args->args_node_allocate.node, &nodeid, status, 1); if (status) { status = -EFAULT; node_delete(node_res, pr_ctxt); } } func_cont: kfree(pargs); return status; }