Fixed
This commit is contained in:
parent
667e48801d
commit
235e53d9b6
17
id/id.c
17
id/id.c
@ -231,3 +231,20 @@ SID *asciiStringToS_id(const char *string){
|
||||
}
|
||||
return s_id;
|
||||
}
|
||||
|
||||
int freeS_id(SID *s_id){
|
||||
if(s_id->value != NULL){
|
||||
free(s_id->value);
|
||||
s_id->value = NULL;
|
||||
}
|
||||
if(s_id->value_deeper != NULL){
|
||||
free(s_id->value_deeper);
|
||||
s_id->value_deeper = NULL;
|
||||
}
|
||||
if(s_id->value_deepest != NULL){
|
||||
free(s_id->value_deepest);
|
||||
s_id->value_deepest = NULL;
|
||||
}
|
||||
free(s_id);
|
||||
return 0;
|
||||
}
|
||||
|
1
id/id.h
1
id/id.h
@ -37,5 +37,6 @@ char *s_idToASCIIString(const SID *s_id);
|
||||
SID *asciiStringToS_id(const char *string);
|
||||
|
||||
SID *initS_id(unsigned int deep_level);
|
||||
int freeS_id(SID *s_id);
|
||||
|
||||
#endif /* id_h */
|
||||
|
12
list/list.c
12
list/list.c
@ -82,7 +82,6 @@ int releaseAllForNode(void) {
|
||||
Node *initNode(void) {
|
||||
Node *p_node = (Node *)malloc(sizeof(Node));
|
||||
Node *prec_node = NULL;
|
||||
p_node->id = getId();
|
||||
p_node->s_id = getS_id(LIST_NODE, 2);
|
||||
p_node->if_malloc = 0;
|
||||
p_node->next = NULL;
|
||||
@ -101,7 +100,6 @@ Node *initNode(void) {
|
||||
List *initList(void) {
|
||||
Node *p_node;
|
||||
List *p_list = (List *)malloc(sizeof(List));
|
||||
p_list->id = getId();
|
||||
p_list->s_id = getS_id(LIST, 1);
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
@ -172,7 +170,7 @@ int releaseNode(Node *p_node) {
|
||||
p_node->next = NULL;
|
||||
p_node->type = VOID;
|
||||
p_node->value = NULL;
|
||||
p_node->id = 0;
|
||||
freeS_id(p_node->s_id);
|
||||
p_node->if_malloc = 0;
|
||||
free(p_node);
|
||||
return 0;
|
||||
@ -196,7 +194,7 @@ int releaseList(List *p_list) {
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
p_list->length = 0;
|
||||
p_list->id = 0;
|
||||
freeS_id(p_list->s_id)
|
||||
free(p_list);
|
||||
return 0;
|
||||
}
|
||||
@ -204,7 +202,7 @@ int releaseList(List *p_list) {
|
||||
int releaseListForSingle(List *p_list) {
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
p_list->id = 0;
|
||||
freeS_id(p_list->s_id);
|
||||
p_list->length = 0;
|
||||
free(p_list);
|
||||
return 0;
|
||||
@ -424,7 +422,7 @@ int exchangeLocation(Node *p_node, Node *t_node) {
|
||||
|
||||
Node *copyNode(Node *p_node) {
|
||||
Node *t_node = initNode();
|
||||
t_node->id = p_node->id;
|
||||
t_node->s_id = p_node->s_id;
|
||||
t_node->last = p_node->last;
|
||||
t_node->next = p_node->next;
|
||||
t_node->if_malloc = p_node->if_malloc;
|
||||
@ -450,7 +448,7 @@ List *copyList(List *p_list) {
|
||||
}
|
||||
|
||||
int releaseOnlyNode(Node *p_node) {
|
||||
p_node->id = 0;
|
||||
freeS_id(p_node->s_id);
|
||||
p_node->if_malloc = 0;
|
||||
p_node->last = NULL;
|
||||
p_node->next = NULL;
|
||||
|
@ -9,8 +9,7 @@
|
||||
#include "../id/id.h"
|
||||
|
||||
typedef struct Node{
|
||||
unsigned long long id;//唯一标识符
|
||||
SID *s_id;
|
||||
SID *s_id;//唯一标识符
|
||||
void *value;
|
||||
_Bool if_malloc;//记录是否已经初始化值
|
||||
_Bool if_sid;
|
||||
@ -21,8 +20,7 @@ typedef struct Node{
|
||||
|
||||
|
||||
typedef struct List{
|
||||
unsigned long long id;//唯一标识符
|
||||
SID *s_id;
|
||||
SID *s_id;//唯一标识符
|
||||
Node *head;
|
||||
Node *tail;
|
||||
unsigned long long length;//链表长度
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
Stack *initStack(void) {
|
||||
Stack *p_stack = (Stack *)malloc(sizeof(Stack));
|
||||
p_stack->id = getId();
|
||||
p_stack->s_id = getS_id(STACK, 1);
|
||||
p_stack->length = 0;
|
||||
p_stack->top = NULL;
|
||||
@ -11,7 +10,6 @@ Stack *initStack(void) {
|
||||
|
||||
SNode *initSNode(void) {
|
||||
SNode *p_snode = (SNode *)malloc(sizeof(SNode));
|
||||
p_snode->id = getId();
|
||||
p_snode->s_id = getS_id(STACK_NODE, 2);
|
||||
p_snode->if_malloc = 0;
|
||||
p_snode->next = NULL;
|
||||
@ -45,7 +43,7 @@ int releaseStack(Stack *p_stack) {
|
||||
p_sndoe = p_sndoe->next;
|
||||
releaseSNode(pl_snode);
|
||||
}
|
||||
p_stack->id = 0;
|
||||
freeS_id(p_stack->s_id);
|
||||
p_stack->top = NULL;
|
||||
p_stack->length = 0;
|
||||
free(p_stack);
|
||||
@ -53,7 +51,7 @@ int releaseStack(Stack *p_stack) {
|
||||
}
|
||||
|
||||
int releaseSNode(SNode *p_snode) {
|
||||
p_snode->id = 0;
|
||||
freeS_id(p_snode->s_id);
|
||||
free(p_snode->value);
|
||||
p_snode->if_malloc = 0;
|
||||
p_snode->value = NULL;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "../list/list_expand.h"
|
||||
|
||||
typedef struct stack_node{
|
||||
unsigned long long id;
|
||||
SID *s_id;
|
||||
_Bool if_malloc;
|
||||
_Bool if_sid;
|
||||
@ -15,7 +14,6 @@ typedef struct stack_node{
|
||||
} SNode;
|
||||
|
||||
typedef struct stack{
|
||||
unsigned long long id;
|
||||
SID *s_id;
|
||||
unsigned long long length;
|
||||
SNode *top;
|
||||
|
16
tree/tree.c
16
tree/tree.c
@ -30,8 +30,7 @@ int safeModeForTree(int ifon) {
|
||||
|
||||
TNode *initTNode(void) {
|
||||
Node *s_node;
|
||||
TNode *p_tnode = (TNode *)malloc(sizeof(TNode));
|
||||
p_tnode->id = getId();
|
||||
TNode *p_tnode = (TNode *)malloc(sizeof(TNode));
|
||||
p_tnode->s_id = getS_id(TREE_NODE, 2);
|
||||
p_tnode->child_num = 0;
|
||||
p_tnode->father = NULL;
|
||||
@ -60,8 +59,7 @@ TNode *initTNode(void) {
|
||||
|
||||
Tree *initTree(void) {
|
||||
Node *s_node;
|
||||
Tree *p_tree = (Tree *)malloc(sizeof(Tree));
|
||||
p_tree->id = getId();
|
||||
Tree *p_tree = (Tree *)malloc(sizeof(Tree));
|
||||
p_tree->s_id = getS_id(TREE, 1);
|
||||
p_tree->root = NULL;
|
||||
if (if_safeModeForTree) {
|
||||
@ -270,7 +268,7 @@ unsigned long long getIndexByChild(TNode *f_tnode, TNode *c_tnode) {
|
||||
int m_index = 0;
|
||||
while (p_node != NULL) {
|
||||
TNode *p_tnode = (TNode *)p_node->value;
|
||||
if (p_tnode->id == c_tnode->id) {
|
||||
if (p_tnode->s_id == c_tnode->s_id) {
|
||||
return m_index;
|
||||
}
|
||||
m_index++;
|
||||
@ -387,7 +385,7 @@ int releaseTNode(TNode *p_tnode) {
|
||||
}
|
||||
p_tnode->value = NULL;
|
||||
p_tnode->type = VOID;
|
||||
p_tnode->id = 0;
|
||||
freeS_id(p_tnode->s_id);
|
||||
p_tnode->if_malloc = 0;
|
||||
free(p_tnode);
|
||||
}
|
||||
@ -397,7 +395,7 @@ int releaseTNode(TNode *p_tnode) {
|
||||
int releaseTree(Tree *p_tree) {
|
||||
TreeThroughUp(p_tree, _doreleaseTree);
|
||||
p_tree->root = NULL;
|
||||
p_tree->id = 0;
|
||||
freeS_id(p_tree->s_id);
|
||||
free(p_tree);
|
||||
return 0;
|
||||
}
|
||||
@ -408,7 +406,7 @@ int _doreleaseTree(TNode *p_tnode, unsigned long long height) {
|
||||
}
|
||||
|
||||
int releaseOnlyTree(Tree *p_tree) {
|
||||
p_tree->id = 0;
|
||||
freeS_id(p_tree->s_id);
|
||||
p_tree->root = NULL;
|
||||
free(p_tree);
|
||||
return 0;
|
||||
@ -428,7 +426,7 @@ int releaseOnlyTNode(TNode *p_tnode) {
|
||||
}
|
||||
p_tnode->value = NULL;
|
||||
p_tnode->type = VOID;
|
||||
p_tnode->id = 0;
|
||||
freeS_id(p_tnode->s_id);
|
||||
p_tnode->if_malloc = 0;
|
||||
free(p_tnode);
|
||||
return 0;
|
||||
|
@ -5,8 +5,7 @@
|
||||
#include "../list/list_expand.h"
|
||||
|
||||
typedef struct tree_node
|
||||
{
|
||||
unsigned long long id;
|
||||
{
|
||||
SID *s_id;
|
||||
List *home;
|
||||
struct tree_node *father;
|
||||
@ -19,8 +18,7 @@ typedef struct tree_node
|
||||
}TNode;
|
||||
|
||||
typedef struct tree
|
||||
{
|
||||
unsigned long long id;
|
||||
{
|
||||
SID *s_id;
|
||||
_Bool if_sid;
|
||||
TNode *root;
|
||||
|
Loading…
Reference in New Issue
Block a user