Implement branch deleting with reparent
This commit is contained in:
parent
fd25215671
commit
91eacbb8c7
24
src/main.c
24
src/main.c
|
@ -41,29 +41,13 @@ int main(int argc, char* *argv){
|
|||
NOD_NodeAddChild(bsd, openbsd);
|
||||
NOD_NodeAddChild(bsd, debianbsd);
|
||||
|
||||
NOD_DestroyNodeBranch(bsd);
|
||||
NOD_DestroyNodeBranch(ubuntu);
|
||||
|
||||
//NOD_NodeUnparent(child2);
|
||||
|
||||
NOD_PrintNodeTree(distros);
|
||||
NOD_PrintNodeTree(arch);
|
||||
NOD_PrintNodeTree(linoox);
|
||||
NOD_PrintNodeTree(debian);
|
||||
NOD_PrintNodeTree(freebsd);
|
||||
|
||||
NOD_DestroyNode(distros);
|
||||
NOD_DestroyNode(linoox);
|
||||
NOD_DestroyNode(debian);
|
||||
NOD_DestroyNode(ubuntu);
|
||||
NOD_DestroyNode(mint);
|
||||
NOD_DestroyNode(devuan);
|
||||
NOD_DestroyNode(kali);
|
||||
NOD_DestroyNode(voidlinux);
|
||||
NOD_DestroyNode(arch);
|
||||
NOD_DestroyNode(manjaro);
|
||||
NOD_DestroyNode(parabola);
|
||||
NOD_DestroyNode(endeavouros);
|
||||
NOD_DestroyNode(bsd);
|
||||
NOD_DestroyNode(freebsd);
|
||||
NOD_DestroyNode(openbsd);
|
||||
NOD_DestroyNode(debianbsd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
11
src/node.c
11
src/node.c
|
@ -20,10 +20,21 @@ NOD_Node *NOD_CreateNode(char *name){
|
|||
|
||||
void NOD_DestroyNode(NOD_Node *node){
|
||||
if(node != NULL){
|
||||
printf("[ INF ] Deleting node \"%s\"\n", node->name);
|
||||
NOD_NodeUnparent(node);
|
||||
free(node);
|
||||
}
|
||||
}
|
||||
|
||||
void NOD_DestroyNodeBranch(NOD_Node *node){
|
||||
if(node != NULL){
|
||||
for(int i = 0; i < node->childc && node->childv != NULL; i++){
|
||||
NOD_DestroyNodeBranch(node->childv[i]);
|
||||
}
|
||||
NOD_DestroyNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
void NOD_NodeAddChild(NOD_Node *parent, NOD_Node *child){
|
||||
if(parent != NULL && child != NULL){
|
||||
/** Prevent recursion */
|
||||
|
|
|
@ -15,6 +15,7 @@ typedef struct node{
|
|||
|
||||
NOD_Node *NOD_CreateNode(char *name);
|
||||
void NOD_DestroyNode(NOD_Node *node);
|
||||
void NOD_DestroyNodeBranch(NOD_Node *node);
|
||||
|
||||
void NOD_NodeAddChild(NOD_Node *parent, NOD_Node *child);
|
||||
void NOD_NodeUnparent(NOD_Node *child);
|
||||
|
|
Loading…
Reference in New Issue