int main(void) { link_t t; int i,j,start=0; FILE *fp; fp=fopen("adjacency_list_graph_traversal_depth_first_search_stack.dat","r"); for(i=0;i<V;i++){ adj[i]=allocNode(i); adj[i]->next=NULL; } while(fscanf(fp,"%d%d",&i,&j)==2){ t=allocNode(j); insertNext(adj[i],t); t=allocNode(i); insertNext(adj[j],t); } fclose(fp); print_list(adj); putchar('\n'); puts("traverse:"); traverse(start,visit); putchar('\n'); return(0); }
static tree_sTable * createTree( pwr_tStatus *sts, size_t keySize, ptrdiff_t keyOffset, size_t recordSize, unsigned int allocCount, int (*compareFunc) (tree_sTable *tp, tree_sNode *x, tree_sNode *y)) { tree_sTable *tp; tp = (tree_sTable *) calloc(1, sizeof(*tp)); if (tp == NULL) pwr_Return(NULL, sts, TREE__INSVIRMEM); tp->keySize = keySize; tp->keyOffset = keyOffset; tp->recordSize = recordSize; tp->allocCount = allocCount; tp->compareFunc = compareFunc; tp->null = allocNode(tp, NULL); tp->key = allocNode(tp, NULL); tp->root = tp->null; tp->null->bal = 0; tp->null->left = tp->null; tp->null->right = tp->null; tp->null->parent = tp->null; return tp; }
static tree_sTable * cloneTree(pwr_tStatus *sts, tree_sTable *otp) { tree_sTable *ntp; ntp = (tree_sTable *) calloc(1, sizeof(*ntp)); if (ntp == NULL) pwr_Return(NULL, sts, TREE__INSVIRMEM); ntp->keySize = otp->keySize; ntp->keyOffset = otp->keyOffset; ntp->recordSize = otp->recordSize; ntp->allocCount = otp->allocCount; ntp->null = allocNode(ntp, NULL); ntp->compareFunc = otp->compareFunc; ntp->key = allocNode(ntp, NULL); ntp->null->bal = 0; ntp->null->left = ntp->null; ntp->null->right = ntp->null; ntp->null->parent = ntp->null; ntp->root = copyNodes(ntp, ntp->null, otp, otp->root); ntp->nNode = otp->nNode; return ntp; }
TEST(BtreeNodeTest, merge_pair_in) { BtreeNode *node = allocNode(); BtreeNode *next_node = allocNode(); node->init(CONST_NODE_OBJECT_COUNT); next_node->init(CONST_NODE_OBJECT_COUNT); node->set_read_only(1); EXPECT_EQ(node->merge_pair_in(next_node), ERROR_CODE_FAIL); node->set_read_only(0); int32_t i = 0; for(i = 0; i < CONST_NODE_OBJECT_COUNT / 2 + 1; i++) { node->add_pair(i, reinterpret_cast<char*>(i), reinterpret_cast<char*>(i), NULL); next_node->add_pair(i, reinterpret_cast<char*>(i), reinterpret_cast<char*>(i), NULL); } EXPECT_EQ(node->merge_pair_in(next_node), ERROR_CODE_FAIL); BtreeKeyValuePair pair; next_node->remove_pair(0, pair); if (CONST_NODE_OBJECT_COUNT % 2 == 0) node->remove_pair(0, pair); EXPECT_EQ(node->merge_pair_in(next_node), ERROR_CODE_OK); free(node); free(next_node); }
int main(int argc,char *argv[]) { link_t *head,t; int i,j; FILE *fp; V=atoi(argv[1]); head=malloc(V*sizeof(link_t)); fp=fopen("adjacency_list_graph_representation.dat","r"); for(i=0;i<V;i++){ head[i]=allocNode(i); head[i]->next=NULL; } while(fscanf(fp,"%d%d",&i,&j)==2){ t=allocNode(j); insertNext(head[i],t); t=allocNode(i); insertNext(head[j],t); } fclose(fp); print_list(head); return(0); }
TEST(BtreeNodeTest, move_pair_in) { BtreeNode *node = allocNode(); BtreeNode *next_node = allocNode(); node->init(CONST_NODE_OBJECT_COUNT); next_node->init(CONST_NODE_OBJECT_COUNT); node->set_read_only(1); EXPECT_EQ(node->move_pair_in(next_node, 1), ERROR_CODE_FAIL); node->set_read_only(0); next_node->set_read_only(1); EXPECT_EQ(node->move_pair_in(next_node, 1), ERROR_CODE_FAIL); next_node->set_read_only(0); EXPECT_EQ(node->move_pair_in(next_node, 0), ERROR_CODE_FAIL); EXPECT_EQ(node->move_pair_in(next_node, 1), ERROR_CODE_FAIL); for(int32_t i = 0; i < CONST_NODE_OBJECT_COUNT - 1; i++) { node->add_pair(i, reinterpret_cast<char*>(i), reinterpret_cast<char*>(i), NULL); next_node->add_pair(i, reinterpret_cast<char*>(i), reinterpret_cast<char*>(i), NULL); } EXPECT_EQ(node->move_pair_in(next_node, 2), ERROR_CODE_FAIL); EXPECT_EQ(node->move_pair_in(next_node, 1), ERROR_CODE_OK); free(node); free(next_node); }
int main(void) { link_t head[V],t; int i,j; FILE *fp; fp=fopen("adjacency_list_graph_representation.dat","r"); for(i=0;i<V;i++){ head[i]=allocNode(i); head[i]->next=NULL; } while(fscanf(fp,"%d%d",&i,&j)==2){ t=allocNode(j); insertNext(head[i],t); t=allocNode(i); insertNext(head[j],t); } fclose(fp); print_list(head); return(0); }
void ptree_Init( pool_sHead *php, ptree_sGtable *gttp, size_t keySize, ptrdiff_t keyOffset, size_t recordSize, unsigned int allocCount) { pwr_tStatus sts; ptree_sNode *nullp; ptree_sTable t; gttp->keySize = keySize; gttp->keyOffset = keyOffset; gttp->recordSize = recordSize; gttp->allocCount = allocCount; t.g = gttp; t.php = php; gttp->null = allocNode( &t, NULL); gttp->key = allocNode( &t, NULL); gttp->root = gttp->null; nullp = pool_Address( &sts, php, gttp->null); nullp->bal = 0; nullp->left = gttp->null; nullp->right = gttp->null; nullp->parent = gttp->null; }
/* ====================== ReadActionNode Parses and creates an AIGenericNode_t with the type ACTION_NODE from a token list The token list pointer is modified to point to the beginning of the next node text block after reading An action node has the form: action name( p1, p2, ... ) Where name defines the action to execute, and the parameters are surrounded by parenthesis ====================== */ AIGenericNode_t *ReadActionNode( pc_token_list **tokenlist ) { pc_token_list *current = *tokenlist; pc_token_list *parenBegin; AIActionNode_t *ret = nullptr; AIActionNode_t node; struct AIActionMap_s *action = nullptr; if ( !expectToken( "action", ¤t, true ) ) { return nullptr; } if ( !current ) { Log::Warn( "Unexpected end of file after line %d", (*tokenlist)->token.line ); return nullptr; } action = (struct AIActionMap_s*) bsearch( current->token.string, AIActions, ARRAY_LEN( AIActions ), sizeof( *AIActions ), cmdcmp ); if ( !action ) { Log::Warn( "%s on line %d is not a valid action", current->token.string, current->token.line ); *tokenlist = current; return nullptr; } parenBegin = current->next; memset( &node, 0, sizeof( node ) ); BotInitNode( ACTION_NODE, action->run, &node ); // allow dropping of parenthesis if we don't require any parameters if ( action->minparams == 0 && parenBegin->token.string[0] != '(' ) { ret = allocNode( AIActionNode_t ); memcpy( ret, &node, sizeof( node ) ); *tokenlist = parenBegin; return ( AIGenericNode_t * ) ret; } node.params = parseFunctionParameters( ¤t, &node.nparams, action->minparams, action->maxparams ); if ( !node.params && action->minparams > 0 ) { return nullptr; } // create the action node ret = allocNode( AIActionNode_t ); memcpy( ret, &node, sizeof( *ret ) ); *tokenlist = current; return ( AIGenericNode_t * ) ret; }
/* ============================================================================= * makeNode * ============================================================================= */ static adtree_node_t* makeNode (long parentIndex, long index, long start, long numRecord, data_t* dataPtr) { adtree_node_t* nodePtr = allocNode(index); assert(nodePtr); nodePtr->count = numRecord; vector_t* varyVectorPtr = nodePtr->varyVectorPtr; long v; long numVar = dataPtr->numVar; for (v = (index + 1); v < numVar; v++) { adtree_vary_t* varyPtr = makeVary(parentIndex, v, start, numRecord, dataPtr); assert(varyPtr); bool_t status = vector_pushBack(varyVectorPtr, (void*)varyPtr); assert(status); } return nodePtr; }
void taskwdInsert(epicsThreadId tid, TASKWDFUNC callback, void *usr) { struct tNode *pt; struct mNode *pm; taskwdInit(); if (tid == 0) tid = epicsThreadGetIdSelf(); pt = &allocNode()->t; pt->tid = tid; pt->callback = callback; pt->usr = usr; pt->suspended = FALSE; epicsMutexMustLock(mLock); pm = (struct mNode *)ellFirst(&mList); while (pm) { if (pm->funcs->insert) { pm->funcs->insert(pm->usr, tid); } pm = (struct mNode *)ellNext(&pm->node); } epicsMutexUnlock(mLock); epicsMutexMustLock(tLock); ellAdd(&tList, (void *)pt); epicsMutexUnlock(tLock); }
/* ============================================================================= * net_alloc * ============================================================================= */ net_t* net_alloc (long numNode) { net_t* netPtr; netPtr = (net_t*)SEQ_MALLOC(sizeof(net_t)); if (netPtr) { vector_t* nodeVectorPtr = vector_alloc(numNode); if (nodeVectorPtr == NULL) { SEQ_FREE(netPtr); return NULL; } long i; for (i = 0; i < numNode; i++) { net_node_t* nodePtr = allocNode(i); if (nodePtr == NULL) { long j; for (j = 0; j < i; j++) { nodePtr = (net_node_t*)vector_at(nodeVectorPtr, j); freeNode(nodePtr); } vector_free(nodeVectorPtr); SEQ_FREE(netPtr); return NULL; } bool_t status = vector_pushBack(nodeVectorPtr, (void*)nodePtr); assert(status); } netPtr->nodeVectorPtr = nodeVectorPtr; } return netPtr; }
TEST(BtreeNodeTest, set_pair) { BtreeNode *node = allocNode(); node->init(CONST_NODE_OBJECT_COUNT); EXPECT_EQ(node->set_pair(-1, NULL, NULL, 0, NULL), ERROR_CODE_FAIL); EXPECT_EQ(node->set_pair(0, NULL, NULL, 0, NULL), ERROR_CODE_FAIL); EXPECT_EQ(node->add_pair(0, reinterpret_cast<char*>(19), reinterpret_cast<char*>(20), NULL), ERROR_CODE_OK); EXPECT_EQ(node->set_pair(0, NULL, reinterpret_cast<char*>(21), 2, NULL), ERROR_CODE_OK); BtreeKeyValuePair *key = node->get_pair(0); EXPECT_EQ(key->key_, reinterpret_cast<char*>(19)); EXPECT_EQ(key->value_, reinterpret_cast<char*>(21)); EXPECT_EQ(node->set_pair(0, reinterpret_cast<char*>(1), reinterpret_cast<char*>(2), 3, NULL), ERROR_CODE_OK); key = node->get_pair(0); EXPECT_EQ(key->key_, reinterpret_cast<char*>(1)); EXPECT_EQ(key->value_, reinterpret_cast<char*>(2)); EXPECT_EQ(node->set_pair(0, reinterpret_cast<char*>(3), NULL, 1, NULL), ERROR_CODE_OK); key = node->get_pair(0); EXPECT_EQ(key->key_, reinterpret_cast<char*>(3)); EXPECT_EQ(key->value_, reinterpret_cast<char*>(2)); node->set_read_only(1); EXPECT_EQ(node->set_pair(0, reinterpret_cast<char*>(4), NULL, 1, NULL), ERROR_CODE_FAIL); free(node); }
/* ============================================================================= * list_insert * -- Return TRUE on success, else FALSE * ============================================================================= */ bool_t list_insert (list_t* listPtr, void* dataPtr) { list_node_t* prevPtr; list_node_t* nodePtr; list_node_t* currPtr; prevPtr = findPrevious(listPtr, dataPtr); currPtr = prevPtr->nextPtr; #ifdef LIST_NO_DUPLICATES if ((currPtr != NULL) && listPtr->compare(currPtr->dataPtr, dataPtr) == 0) { return FALSE; } #endif nodePtr = allocNode(dataPtr); if (nodePtr == NULL) { return FALSE; } nodePtr->nextPtr = currPtr; prevPtr->nextPtr = nodePtr; listPtr->size++; return TRUE; }
void JunctionPoints::refresh(void) { JunctionSelection* selection = static_cast<JunctionSelection*>( getSceneManipulator()->_getSelection("JunctionSelection")); const JunctionSelection::JunctionMap& junctions = selection->getJunctions(); DisplayNodes newDisplayNodes; // Use existing point if possible for (JunctionSelection::JunctionMap::const_iterator it = junctions.begin(); it != junctions.end(); ++it) { const JunctionSelection::Junction& junction = it->second; Ogre::Vector3 pos = getTerrainData()->_getPosition(junction.x, junction.z); DisplayNodes::iterator found = mDisplayNodes.find(Ogre::Vector4(pos.x, pos.y, pos.z, junction.weight)); Ogre::SceneNode* node = NULL; if (found != mDisplayNodes.end()) { node = found->second; mDisplayNodes.erase(found); } newDisplayNodes.insert(DisplayNodes::value_type(Ogre::Vector4(pos.x, pos.y, pos.z, junction.weight), node)); } // Build new point and adjust position for (DisplayNodes::iterator it = newDisplayNodes.begin(); it != newDisplayNodes.end(); ++it) { if (!it->second) { if (!mDisplayNodes.empty()) { DisplayNodes::iterator found = mDisplayNodes.begin(); it->second = found->second; mDisplayNodes.erase(found); } else { it->second = allocNode(); } it->second->setPosition(it->first.x,it->first.y,it->first.z); // 根据节点的权重来设置节点所挂物体的材质颜色 Ogre::MaterialPtr material = createPureColourMaterial(Ogre::ColourValue(it->first.w,(1.0f-it->first.w),0.0f)); // 设置节点的材质 static_cast<Ogre::Entity *>(it->second->getAttachedObject(0))->setMaterialName(material->getName()); } } // Hide extra points for (DisplayNodes::const_iterator it = mDisplayNodes.begin(); it != mDisplayNodes.end(); ++it) { freeNode(it->second); } std::swap(newDisplayNodes, mDisplayNodes); }
TEST(BtreeNodeTest, key_refcount) { BtreeNode *node = allocNode(); node->init(CONST_NODE_OBJECT_COUNT); BtreeDefaultAlloc allocator; char *key = allocator.alloc(); int32_t *addr = reinterpret_cast<int32_t*>(key); (*addr) = 1; node->add_pair(0, key, reinterpret_cast<char*>(1), NULL); node->inc_key_refcount(); EXPECT_EQ(*addr, 1); node->dec_key_refcount(&allocator); EXPECT_EQ(*addr, 1); node->set_leaf(1); node->inc_key_refcount(); EXPECT_EQ(*addr, 2); node->dec_key_refcount(&allocator); EXPECT_EQ(*addr, 1); node->dec_key_refcount(&allocator); #ifndef OCEAN_BASE_BTREE_USE_SYS_MALLOC EXPECT_EQ(*addr, 0); #endif node->set_sequence(1); EXPECT_EQ(node->get_sequence(), 1); free(node); }
bool list_cgl::add(int val) { //fprintf(dbgLogs,"\nadd(%d) invoked",val); //fflush(dbgLogs); bool retVal = false; mtx.lock(); pNode pred = head; pNode curr = pred->next; while(curr->val < val) { pred = curr; curr = curr->next; } if(curr->val == val) { retVal = false; } else { pNode node = allocNode(val); node->next = curr; pred->next = node; retVal = true; } mtx.unlock(); return retVal; }
Node *createNewNode(void) { Node *newNode = allocNode(); assert(newNode); newNode = initNode(newNode); return newNode; }
/*insert a element into the binarySearchTree. * if insert success,return true; * else return false.*/ bool insertIntoBSTree(BSTNode **pRoot,int element){ if(NULL == pRoot) return false; if(NULL == *pRoot){ *pRoot = allocNode(element); return NULL==*pRoot?false:true; } BSTNode **pSrc = NULL; if(searchInBSTree(pRoot,element,pSrc)) return false; BSTNode *pNode = allocNode(element); if(element < *pSrc->element) *pSrc->pLeft = pNode; else *pSrc->pRight = pNode; return true; }
bool insertIntoRedBlackTree(RBNode **pRoot,int element){ if(pRoot == NULL) return false; RBNode *pNode = allocNode(element); /* the inserted node is the root node.*/ if(NULL == *pRoot){ *pRoot = pNode; *pRoot->color = RB_BLACK; return true; } RBNode *pTemp = *pRoot; while(1){ if(pTemp->element > element){ if(NULL == pTemp->pLeft){ pTemp->pLeft = pNode; pNode->pParent = pTemp; break; } pTemp = pTemp->pLeft; } else{ if(NULL == pTemp->pRight){ pTemp->pRight = pNode; pNode->pParent = pTemp; break; } pTemp = pTemp->pRight; } } /* the parent node of the inserted node is black.*/ if(RB_BLACK == pTemp->color) return true; /* the parent node of the inserted node is red.*/ while(pTemp->pParent){ pTemp = pTemp->pParent; if(pTemp->pLeft == pTemp && NULL != pTemp->pRight){ if(pTemp->pRight->color == RB_RED) pTemp->pLeft->color = pTemp->pRight->color = RB_BLACK; else{ } } else if(NULL == pTemp->pRight){ pTemp->pLeft->color = RB_BLACK; } else if(pTemp->pRight == pTemp && NULL != pTemp->pLeft){ if(pTemp->pLeft->color == RB_RED) pTemp->pLeft->color = pTemp->pRight->color = RB_BLACK; else{ } } else if(NULL == pTemp->pLeft){ pTemp->pRight->color = RB_BLACK; } } }
int PhoneLookup::getNode( int parentNode , char sepChar , int monoInd , bool addNew ) { if ( (monoInd < 0) || (monoInd >= monoLookup->getNumMonophones()) ) error("PhoneLookup::allocNode - monoInd=%d out of range" , monoInd) ; int node=-1 ; if ( parentNode < 0 ) { if ( sepChar != '\0' ) error("PhoneLookup::getNode - expect sepChar==nul when parentNode<0") ; // look in firstLevelNodes if ( (firstLevelNodes[monoInd] < 0) && addNew ) { firstLevelNodes[monoInd] = allocNode( '\0' , monoInd ) ; } node = firstLevelNodes[monoInd] ; } else { // search through the children of 'parentNode' looking for a node // with monoInd field equal to 'monoInd' and sepChar field equal to 'sepChar'. node = nodes[parentNode].firstChild ; while ( node >= 0 ) { if ( (nodes[node].monoInd == monoInd) && (nodes[node].sepChar == sepChar) ) break ; node = nodes[node].nextSib ; } if ( (node < 0) && addNew ) { node = allocNode( sepChar , monoInd ) ; nodes[node].nextSib = nodes[parentNode].firstChild ; nodes[parentNode].firstChild = node ; } } return node ; }
/* * Do some basic list manipulations and output to log for * script comparison. Only testing the macros we use. */ int main(int argc, char *argv[]) { PTEST_NODE pNode = NULL; START(argc, argv, "win_lists"); LIST_INIT(&TestListHead); UT_ASSERT_rt(LIST_EMPTY(&TestListHead)); pNode = allocNode(); pNode->dummy = 0; LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry); UT_ASSERTeq_rt(1, getListCount()); dump_list(); /* Remove one node */ LIST_REMOVE(pNode, ListEntry); UT_ASSERTeq_rt(0, getListCount()); dump_list(); free(pNode); /* Add a bunch of nodes */ for (int i = 1; i < 10; i++) { pNode = allocNode(); pNode->dummy = i; LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry); } UT_ASSERTeq_rt(9, getListCount()); dump_list(); /* Remove all of them */ while (!LIST_EMPTY(&TestListHead)) { PTEST_NODE pNode = (PTEST_NODE)LIST_FIRST(&TestListHead); LIST_REMOVE(pNode, ListEntry); free(pNode); } UT_ASSERTeq_rt(0, getListCount()); dump_list(); DONE(NULL); }
void taskwdAnyInsert(void *key, TASKWDANYFUNC callback, void *usr) { struct mNode *pm; struct aNode *pa; if (callback == NULL) return; taskwdInit(); pa = &allocNode()->a; pa->key = key; pa->callback = callback; pa->usr = usr; pm = &allocNode()->m; pm->funcs = &anyFuncs; pm->usr = pa; epicsMutexMustLock(mLock); ellAdd(&mList, (void *)pm); epicsMutexUnlock(mLock); }
int MonophoneLookup::getNode( int parentNode , char chr , bool addNew ) { int node=-1 ; if ( chr < 0 ) error("MonophoneLookup::getNode - chr=%c out of range" , chr) ; if ( parentNode < 0 ) { // look in firstLevelNodes if ( firstLevelNodes[chr] < 0 ) { firstLevelNodes[chr] = allocNode( chr ) ; } node = firstLevelNodes[chr] ; } else { // search through the children of 'parentNode' looking for a node // with chr field equal to 'chr'. node = nodes[parentNode].firstChild ; while ( node >= 0 ) { if ( nodes[node].chr == chr ) break ; node = nodes[node].nextSib ; } if ( (node < 0) && addNew ) { node = allocNode( chr ) ; nodes[node].nextSib = nodes[parentNode].firstChild ; nodes[parentNode].firstChild = node ; } } return node ; }
tuint SWDynamicTree2D::createProxy( const taabb2d& aabb, void* userData ) { tuint proxyID = allocNode(); tvec2 extension( SW_AddedExtension, SW_AddedExtension ); TreeNode& node = m_nodes[proxyID]; node.aabb = aabb; node.aabb.lower -= extension; node.aabb.upper += extension; node.userData = userData; insertLeaf( proxyID ); return proxyID; }
TEST(BtreeNodeTest, remove_pair) { BtreeNode *node = allocNode(); node->init(CONST_NODE_OBJECT_COUNT); for(int32_t i = 0; i < CONST_NODE_OBJECT_COUNT; i++) { EXPECT_EQ(node->add_pair(i, "", reinterpret_cast<char*>(i + 1), NULL), ERROR_CODE_OK); } BtreeKeyValuePair pair; EXPECT_EQ(node->remove_pair(-1, pair), ERROR_CODE_FAIL); EXPECT_EQ(node->remove_pair(CONST_NODE_OBJECT_COUNT, pair), ERROR_CODE_FAIL); node->set_read_only(1); EXPECT_EQ(node->remove_pair(0, pair), ERROR_CODE_FAIL); free(node); }
void taskwdMonitorAdd(const taskwdMonitor *funcs, void *usr) { struct mNode *pm; if (funcs == NULL) return; taskwdInit(); pm = &allocNode()->m; pm->funcs = funcs; pm->usr = usr; epicsMutexMustLock(mLock); ellAdd(&mList, (void *)pm); epicsMutexUnlock(mLock); }
/* ====================== ReadNodeList Parses and creates an AINodeList_t from a token list The token list pointer is modified to point to the beginning of the next node text block after reading ====================== */ AIGenericNode_t *ReadNodeList( pc_token_list **tokenlist ) { AINodeList_t *list; pc_token_list *current = *tokenlist; if ( !expectToken( "{", ¤t, true ) ) { return nullptr; } list = allocNode( AINodeList_t ); while ( Q_stricmp( current->token.string, "}" ) ) { AIGenericNode_t *node = ReadNode( ¤t ); if ( node && list->numNodes >= MAX_NODE_LIST ) { Log::Warn( "Max selector children limit exceeded at line %d", (*tokenlist)->token.line ); FreeNode( node ); FreeNodeList( list ); *tokenlist = current; return nullptr; } else if ( node ) { list->list[ list->numNodes ] = node; list->numNodes++; } if ( !node ) { *tokenlist = current; FreeNodeList( list ); return nullptr; } if ( !current ) { *tokenlist = current; return ( AIGenericNode_t * ) list; } } *tokenlist = current->next; return ( AIGenericNode_t * ) list; }
TEST(BtreeNodeTest, init) { BtreeNode *node = allocNode(); EXPECT_EQ(node->init(1), ERROR_CODE_OK); EXPECT_EQ(node->init(0), ERROR_CODE_FAIL); node->set_deleted(1000); EXPECT_EQ(node->is_deleted(), 1); node->set_deleted(0); EXPECT_EQ(node->is_deleted(), 0); node->set_read_only(1000); EXPECT_EQ(node->is_read_only(), 1); node->set_read_only(0); EXPECT_EQ(node->is_read_only(), 0); free(node); BtreeNode node1; EXPECT_EQ(node1.get_size(), 0); }
static tree_sNode * copyNodes(tree_sTable *ntp, tree_sNode *parent, tree_sTable *otp, tree_sNode *onp) { tree_sNode *nnp; if (onp == otp->null) return ntp->null; nnp = allocNode(ntp, NULL); memcpy(nnp, onp, ntp->recordSize); nnp->parent = parent; nnp->left = copyNodes(ntp, nnp, otp, onp->left); nnp->right = copyNodes(ntp, nnp, otp, onp->right); return nnp; }