Merge branch 'develop' of https://github.com/saturneric/ZE-Standard-Libraries into develop
This commit is contained in:
commit
1fdb271174
@ -8,6 +8,15 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
9246995F20CE655900B4E894 /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995E20CE655900B4E894 /* tree.c */; };
|
9246995F20CE655900B4E894 /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995E20CE655900B4E894 /* tree.c */; };
|
||||||
|
9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E7210F1B3D00161557 /* stack_expand.c */; };
|
||||||
|
9269D4EA210F1B4B00161557 /* list_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4E9210F1B4B00161557 /* list_expand.c */; };
|
||||||
|
9269D4ED210F1B5E00161557 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4EB210F1B5E00161557 /* test.c */; };
|
||||||
|
9269D4F4210F1BB000161557 /* id.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4F2210F1BB000161557 /* id.c */; };
|
||||||
|
9269D4F5210F1BCE00161557 /* list.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246994F20CD000300B4E894 /* list.c */; };
|
||||||
|
9269D4F6210F1CD900161557 /* stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 9246995920CE52A700B4E894 /* stack.c */; };
|
||||||
|
9269D4F8210F1D0B00161557 /* tree_expand.c in Sources */ = {isa = PBXBuildFile; fileRef = 9269D4F7210F1D0B00161557 /* tree_expand.c */; };
|
||||||
|
9286EB7A211400C900752977 /* error.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB79211400C900752977 /* error.c */; };
|
||||||
|
9286EB7E2114022A00752977 /* communicate.c in Sources */ = {isa = PBXBuildFile; fileRef = 9286EB7D2114022A00752977 /* communicate.c */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@ -31,7 +40,20 @@
|
|||||||
9246995B20CE5C8900B4E894 /* stack_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack_expand.h; sourceTree = "<group>"; };
|
9246995B20CE5C8900B4E894 /* stack_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack_expand.h; sourceTree = "<group>"; };
|
||||||
9246995D20CE655900B4E894 /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
|
9246995D20CE655900B4E894 /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
|
||||||
9246995E20CE655900B4E894 /* tree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; };
|
9246995E20CE655900B4E894 /* tree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; };
|
||||||
|
9269D4E7210F1B3D00161557 /* stack_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_expand.c; sourceTree = "<group>"; };
|
||||||
|
9269D4E9210F1B4B00161557 /* list_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = list_expand.c; sourceTree = "<group>"; };
|
||||||
|
9269D4EB210F1B5E00161557 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test.c; sourceTree = "<group>"; };
|
||||||
|
9269D4EC210F1B5E00161557 /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = test.h; sourceTree = "<group>"; };
|
||||||
|
9269D4F0210F1B8000161557 /* type.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = type.h; path = type/type.h; sourceTree = "<group>"; };
|
||||||
|
9269D4F2210F1BB000161557 /* id.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = id.c; path = id/id.c; sourceTree = "<group>"; };
|
||||||
|
9269D4F3210F1BB000161557 /* id.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = id.h; path = id/id.h; sourceTree = "<group>"; };
|
||||||
|
9269D4F7210F1D0B00161557 /* tree_expand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree_expand.c; sourceTree = "<group>"; };
|
||||||
|
9269D4F9210F1D0F00161557 /* tree_expand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree_expand.h; sourceTree = "<group>"; };
|
||||||
927993BD20CB87D6008CE3A9 /* ZE-Standard-Libraries */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ZE-Standard-Libraries"; sourceTree = BUILT_PRODUCTS_DIR; };
|
927993BD20CB87D6008CE3A9 /* ZE-Standard-Libraries */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ZE-Standard-Libraries"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
9286EB79211400C900752977 /* error.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = error.c; path = error/error.c; sourceTree = "<group>"; };
|
||||||
|
9286EB7B211400D000752977 /* error.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = error.h; path = error/error.h; sourceTree = "<group>"; };
|
||||||
|
9286EB7D2114022A00752977 /* communicate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = communicate.c; path = communicate/communicate.c; sourceTree = "<group>"; };
|
||||||
|
9286EB7F2114022F00752977 /* communicate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = communicate.h; path = communicate/communicate.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -50,6 +72,7 @@
|
|||||||
children = (
|
children = (
|
||||||
9246994F20CD000300B4E894 /* list.c */,
|
9246994F20CD000300B4E894 /* list.c */,
|
||||||
9246995020CD000300B4E894 /* list_expand.h */,
|
9246995020CD000300B4E894 /* list_expand.h */,
|
||||||
|
9269D4E9210F1B4B00161557 /* list_expand.c */,
|
||||||
9246995120CD000300B4E894 /* list.h */,
|
9246995120CD000300B4E894 /* list.h */,
|
||||||
);
|
);
|
||||||
path = list;
|
path = list;
|
||||||
@ -60,6 +83,7 @@
|
|||||||
children = (
|
children = (
|
||||||
9246995820CE52A700B4E894 /* stack.h */,
|
9246995820CE52A700B4E894 /* stack.h */,
|
||||||
9246995920CE52A700B4E894 /* stack.c */,
|
9246995920CE52A700B4E894 /* stack.c */,
|
||||||
|
9269D4E7210F1B3D00161557 /* stack_expand.c */,
|
||||||
9246995B20CE5C8900B4E894 /* stack_expand.h */,
|
9246995B20CE5C8900B4E894 /* stack_expand.h */,
|
||||||
);
|
);
|
||||||
path = stack;
|
path = stack;
|
||||||
@ -70,16 +94,41 @@
|
|||||||
children = (
|
children = (
|
||||||
9246995D20CE655900B4E894 /* tree.h */,
|
9246995D20CE655900B4E894 /* tree.h */,
|
||||||
9246995E20CE655900B4E894 /* tree.c */,
|
9246995E20CE655900B4E894 /* tree.c */,
|
||||||
|
9269D4F9210F1D0F00161557 /* tree_expand.h */,
|
||||||
|
9269D4F7210F1D0B00161557 /* tree_expand.c */,
|
||||||
);
|
);
|
||||||
path = tree;
|
path = tree;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
9269D4EF210F1B7800161557 /* type */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9269D4F0210F1B8000161557 /* type.h */,
|
||||||
|
);
|
||||||
|
name = type;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
9269D4F1210F1B9E00161557 /* id */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9269D4F2210F1BB000161557 /* id.c */,
|
||||||
|
9269D4F3210F1BB000161557 /* id.h */,
|
||||||
|
);
|
||||||
|
name = id;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
927993B420CB87D6008CE3A9 = {
|
927993B420CB87D6008CE3A9 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
9286EB7C2114021E00752977 /* communicate */,
|
||||||
|
9286EB78211400BD00752977 /* error */,
|
||||||
|
9269D4F1210F1B9E00161557 /* id */,
|
||||||
|
9269D4EF210F1B7800161557 /* type */,
|
||||||
9246995C20CE654600B4E894 /* tree */,
|
9246995C20CE654600B4E894 /* tree */,
|
||||||
9246995720CE507900B4E894 /* stack */,
|
9246995720CE507900B4E894 /* stack */,
|
||||||
9246994E20CD000300B4E894 /* list */,
|
9246994E20CD000300B4E894 /* list */,
|
||||||
|
9269D4EB210F1B5E00161557 /* test.c */,
|
||||||
|
9269D4EC210F1B5E00161557 /* test.h */,
|
||||||
927993BE20CB87D6008CE3A9 /* Products */,
|
927993BE20CB87D6008CE3A9 /* Products */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -92,6 +141,24 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
9286EB78211400BD00752977 /* error */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9286EB79211400C900752977 /* error.c */,
|
||||||
|
9286EB7B211400D000752977 /* error.h */,
|
||||||
|
);
|
||||||
|
name = error;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
9286EB7C2114021E00752977 /* communicate */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9286EB7F2114022F00752977 /* communicate.h */,
|
||||||
|
9286EB7D2114022A00752977 /* communicate.c */,
|
||||||
|
);
|
||||||
|
name = communicate;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@ -148,7 +215,16 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
9269D4F6210F1CD900161557 /* stack.c in Sources */,
|
||||||
|
9286EB7A211400C900752977 /* error.c in Sources */,
|
||||||
|
9269D4E8210F1B3D00161557 /* stack_expand.c in Sources */,
|
||||||
|
9286EB7E2114022A00752977 /* communicate.c in Sources */,
|
||||||
|
9269D4EA210F1B4B00161557 /* list_expand.c in Sources */,
|
||||||
|
9269D4F4210F1BB000161557 /* id.c in Sources */,
|
||||||
|
9269D4F8210F1D0B00161557 /* tree_expand.c in Sources */,
|
||||||
9246995F20CE655900B4E894 /* tree.c in Sources */,
|
9246995F20CE655900B4E894 /* tree.c in Sources */,
|
||||||
|
9269D4ED210F1B5E00161557 /* test.c in Sources */,
|
||||||
|
9269D4F5210F1BCE00161557 /* list.c in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -154,7 +154,7 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "test.c"
|
filePath = "test.c"
|
||||||
timestampString = "554017478.314317"
|
timestampString = "554959944.593868"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "64"
|
startingLineNumber = "64"
|
||||||
@ -170,7 +170,7 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "tree/tree_expand.c"
|
filePath = "tree/tree_expand.c"
|
||||||
timestampString = "554017478.3148969"
|
timestampString = "554638722.806551"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "60"
|
startingLineNumber = "60"
|
||||||
|
@ -1,9 +1 @@
|
|||||||
//
|
|
||||||
// communicate.c
|
|
||||||
// ZE-Standard-Libraries
|
|
||||||
//
|
|
||||||
// Created by 胡一兵 on 2018/7/25.
|
|
||||||
// Copyright © 2018年 ZE. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "communicate.h"
|
#include "communicate.h"
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
//
|
|
||||||
// communicate.h
|
|
||||||
// ZE-Standard-Libraries
|
|
||||||
//
|
|
||||||
// Created by 胡一兵 on 2018/7/25.
|
|
||||||
// Copyright © 2018年 ZE. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef communicate_h
|
#ifndef communicate_h
|
||||||
#define communicate_h
|
#define communicate_h
|
||||||
|
|
||||||
|
@ -9,15 +9,13 @@ int initErrorSystem(void) {
|
|||||||
|
|
||||||
int setLogDirectory(const char *path) {
|
int setLogDirectory(const char *path) {
|
||||||
logfile.id = getId();
|
logfile.id = getId();
|
||||||
int memory_space = strlen(path) + 256;
|
unsigned long memory_space = strlen(path) + 256;
|
||||||
char *file_path = (char *)malloc(sizeof(char)*memory_space);
|
char *file_path = (char *)malloc(sizeof(char)*memory_space);
|
||||||
|
|
||||||
//建立完整的文件路径
|
|
||||||
strcat(file_path, path);
|
strcat(file_path, path);
|
||||||
strcat(file_path, "log");
|
strcat(file_path, "log");
|
||||||
sprintf(file_path, "%d", logfile.id);
|
sprintf(file_path, "%lu", logfile.id);
|
||||||
|
|
||||||
//打开文件,若失败,返回0
|
|
||||||
if ((logfile.fp = fopen(file_path, "w")) == NULL) {
|
if ((logfile.fp = fopen(file_path, "w")) == NULL) {
|
||||||
printf("Cannot set logfile!");
|
printf("Cannot set logfile!");
|
||||||
return 0;
|
return 0;
|
||||||
@ -46,6 +44,7 @@ int closeLogDirectory(void) {
|
|||||||
if_error = 0;
|
if_error = 0;
|
||||||
fclose(logfile.fp);
|
fclose(logfile.fp);
|
||||||
logfile.if_enable = 0;
|
logfile.if_enable = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loadFromFile(FILE *fp,char* number) {
|
int loadFromFile(FILE *fp,char* number) {
|
||||||
@ -58,6 +57,7 @@ int pushInfo(Info *p_info, const char *head, const char *body) {
|
|||||||
p_info->body = (char *)malloc(sizeof(char) * strlen(body));
|
p_info->body = (char *)malloc(sizeof(char) * strlen(body));
|
||||||
strcpy(p_info->head, head);
|
strcpy(p_info->head, head);
|
||||||
strcpy(p_info->body, body);
|
strcpy(p_info->body, body);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pushError(unsigned int type, int pri, Info *p_info) {
|
int pushError(unsigned int type, int pri, Info *p_info) {
|
||||||
@ -66,6 +66,7 @@ int pushError(unsigned int type, int pri, Info *p_info) {
|
|||||||
error.priority = pri;
|
error.priority = pri;
|
||||||
error.p_info = p_info;
|
error.p_info = p_info;
|
||||||
error.time = time(NULL);
|
error.time = time(NULL);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pushNotice(unsigned int type, Info *p_info) {
|
int pushNotice(unsigned int type, Info *p_info) {
|
||||||
@ -73,6 +74,7 @@ int pushNotice(unsigned int type, Info *p_info) {
|
|||||||
notice.type = type;
|
notice.type = type;
|
||||||
notice.p_info = p_info;
|
notice.p_info = p_info;
|
||||||
notice.time = time(NULL);
|
notice.time = time(NULL);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int saveError(Error *p_error) {
|
static int saveError(Error *p_error) {
|
||||||
@ -87,6 +89,7 @@ static int saveError(Error *p_error) {
|
|||||||
%s\n\
|
%s\n\
|
||||||
---------------------\n",
|
---------------------\n",
|
||||||
p_error->type, p_error->priority, ctime( &(p_error->time) ), p_error->p_info->head, p_error->p_info->body);
|
p_error->type, p_error->priority, ctime( &(p_error->time) ), p_error->p_info->head, p_error->p_info->body);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static int saveNotice(Notice *p_notice) {
|
static int saveNotice(Notice *p_notice) {
|
||||||
fprintf(logfile.fp,
|
fprintf(logfile.fp,
|
||||||
@ -99,4 +102,5 @@ static int saveNotice(Notice *p_notice) {
|
|||||||
%s\n\
|
%s\n\
|
||||||
----------------------\n",
|
----------------------\n",
|
||||||
p_notice->type, ctime( &(p_notice->time) ), p_notice->p_info->head, p_notice->p_info->body);
|
p_notice->type, ctime( &(p_notice->time) ), p_notice->p_info->head, p_notice->p_info->body);
|
||||||
|
return 0;
|
||||||
}
|
}
|
3
id/id.c
3
id/id.c
@ -173,7 +173,7 @@ char *s_idToASCIIString(const SID *s_id){
|
|||||||
SID *asciiStringToS_id(const char *string){
|
SID *asciiStringToS_id(const char *string){
|
||||||
SID *s_id = NULL;
|
SID *s_id = NULL;
|
||||||
unsigned long long string_len = strlen(string);
|
unsigned long long string_len = strlen(string);
|
||||||
unsigned int buff[string_len - 1];
|
unsigned int *buff = (unsigned int *) malloc(sizeof(string_len - 1));
|
||||||
for(int i = 0; i < string_len; i++){
|
for(int i = 0; i < string_len; i++){
|
||||||
buff[i] = string[i] - 48;
|
buff[i] = string[i] - 48;
|
||||||
}
|
}
|
||||||
@ -221,6 +221,7 @@ SID *asciiStringToS_id(const char *string){
|
|||||||
(*s_id->value_deepest)[i] /= 10;
|
(*s_id->value_deepest)[i] /= 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(buff);
|
||||||
return s_id;
|
return s_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
static int if_safeModeForNode = 0;
|
static int if_safeModeForNode = 0;
|
||||||
static List *node_list = NULL; //储存声明过的节点.
|
static List *node_list = NULL;
|
||||||
static List *list_list = NULL; //储存声明过的链表.
|
static List *list_list = NULL;
|
||||||
|
|
||||||
int safeModeForNode(int ifon) {
|
int safeModeForNode(int ifon) {
|
||||||
if (ifon == 1) {
|
if (ifon == 1) {
|
||||||
|
49
list/list.h
49
list/list.h
@ -9,66 +9,61 @@
|
|||||||
#include "../id/id.h"
|
#include "../id/id.h"
|
||||||
|
|
||||||
typedef struct Node{
|
typedef struct Node{
|
||||||
SID *s_id;//唯一标识符
|
SID *s_id;
|
||||||
void *value;
|
void *value;
|
||||||
_Bool if_malloc;//记录是否已经初始化值
|
_Bool if_malloc;
|
||||||
_Bool if_sid;
|
_Bool if_sid;
|
||||||
unsigned int type;//记录值的类型
|
unsigned int type;
|
||||||
struct Node *next;
|
struct Node *next;
|
||||||
struct Node *last;
|
struct Node *last;
|
||||||
} Node;
|
} Node;
|
||||||
|
|
||||||
|
|
||||||
typedef struct List{
|
typedef struct List{
|
||||||
SID *s_id;//唯一标识符
|
SID *s_id;
|
||||||
Node *head;
|
Node *head;
|
||||||
Node *tail;
|
Node *tail;
|
||||||
unsigned long long length;//链表长度
|
unsigned long long length;
|
||||||
} List;
|
} List;
|
||||||
|
|
||||||
int safeModeForNode(int ifon);//安全模式确保显式声明过的内存都会被释放
|
int safeModeForNode(int ifon);
|
||||||
int releaseSingleListForsafeModeForNode(List *p_list);//释放list_list
|
int releaseSingleListForsafeModeForNode(List *p_list);
|
||||||
int releaseSingleNodeForsafeModeForNode(List *p_list);//释放node_list
|
int releaseSingleNodeForsafeModeForNode(List *p_list);
|
||||||
int releaseAllForNode(void);//安全模式最后调用的函数
|
int releaseAllForNode(void);
|
||||||
|
|
||||||
List *initList(void);
|
List *initList(void);
|
||||||
Node *initNode(void);
|
Node *initNode(void);
|
||||||
|
|
||||||
int initMallocValueForNode(Node *,unsigned int,void *);//赋予已分配内存的值,并标明类型
|
int initMallocValueForNode(Node *,unsigned int,void *);
|
||||||
|
|
||||||
/*插入函数*/
|
|
||||||
int insertInHead(List *p_list, Node *p_node);
|
int insertInHead(List *p_list, Node *p_node);
|
||||||
int insertInTail(List *p_list, Node *p_node);
|
int insertInTail(List *p_list, Node *p_node);
|
||||||
|
|
||||||
/*交换函数*/
|
|
||||||
int exchangeLocation(Node *p_node,Node *t_node);
|
int exchangeLocation(Node *p_node,Node *t_node);
|
||||||
|
|
||||||
/*复制函数*/
|
|
||||||
Node *copyNode(Node *);
|
Node *copyNode(Node *);
|
||||||
|
|
||||||
/*移除函数*/
|
|
||||||
int removeById(List *p_list, const SID *s_id);
|
int removeById(List *p_list, const SID *s_id);
|
||||||
int removeByNode(List *p_list, Node *p_node);
|
int removeByNode(List *p_list, Node *p_node);
|
||||||
int popFromHead(List *p_list);
|
int popFromHead(List *p_list);
|
||||||
int popFromTail(List *p_list);
|
int popFromTail(List *p_list);
|
||||||
|
|
||||||
unsigned long long len(List *p_list);//查看链表的长度
|
unsigned long long len(List *p_list);
|
||||||
|
|
||||||
Node *findByIdForNode(List *p_list, const SID *s_id);//通过id查找目标链表中的匹配节点
|
Node *findByIdForNode(List *p_list, const SID *s_id);
|
||||||
Node *findByValue(List *p_list, unsigned int type, const void *value);//通过值来查找目标链表中的匹配节点
|
Node *findByValue(List *p_list, unsigned int type, const void *value);
|
||||||
List *mply_findByValue(List *p_list, unsigned int type, const void *value);//寻找多个值匹配的节点
|
List *mply_findByValue(List *p_list, unsigned int type, const void *value);
|
||||||
|
|
||||||
int releaseList(List *p_list);//释放List并可选择是否释放中所有的其中的Node
|
int releaseList(List *p_list);
|
||||||
int releaseListForSingle(List *p_list);//单独释放List
|
int releaseListForSingle(List *p_list);
|
||||||
int releaseNode(Node *p_node);//释放Node
|
int releaseNode(Node *p_node);
|
||||||
int releaseOnlyNode(Node *p_node);//释放Node
|
int releaseOnlyNode(Node *p_node);
|
||||||
|
|
||||||
int isListEmpty(List *p_list);//判断List是否为空
|
int isListEmpty(List *p_list);
|
||||||
List *copyList(List *p_list);//复制链表
|
List *copyList(List *p_list);
|
||||||
|
|
||||||
/*有关安全模式的变量*/
|
|
||||||
static int if_safeModeForNode;
|
static int if_safeModeForNode;
|
||||||
static List *node_list; //储存声明过的节点.
|
static List *node_list;
|
||||||
static List *list_list; //储存声明过的链表.
|
static List *list_list;
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,42 +1,41 @@
|
|||||||
#ifndef LIST_EXPAND_H
|
#ifndef LIST_EXPAND_H
|
||||||
#define LIST_EXPAND_H
|
#define LIST_EXPAND_H
|
||||||
#include "list.c"
|
#include "list.h"
|
||||||
|
|
||||||
Node *nodeWithInt(int);//快速初始化一个单一值节点并赋值
|
Node *nodeWithInt(int);
|
||||||
Node *nodeWithDouble(double);//快速初始化一个节单一值点并赋值
|
Node *nodeWithDouble(double);
|
||||||
Node *nodeWithString(const char *);//快速初始化一个单一值节点并赋值
|
Node *nodeWithString(const char *);
|
||||||
Node *nodeWithPointer(void *);//快速初始化一个单一值节点并赋值
|
Node *nodeWithPointer(void *);
|
||||||
|
|
||||||
Node *nodeWithComplex(void);//快速初始化一个复合值节点并赋值
|
Node *nodeWithComplex(void);
|
||||||
int addValueForComplex(Node *, int type, void *value);//为复合节点添加值
|
int addValueForComplex(Node *, int type, void *value);
|
||||||
int addIntForComplex(Node *, int);//为复合节点添加一个特定类型的值
|
int addIntForComplex(Node *, int);
|
||||||
int addDoubleForComplex(Node *, double);//为复合节点添加一个特定类型的值
|
int addDoubleForComplex(Node *, double);
|
||||||
int addStringForComplex(Node *, char *);//为复合节点添加一个特定类型的值
|
int addStringForComplex(Node *, char *);
|
||||||
int addPointerForComplex(Node *, void *);//为复合节点添加一个特定类型的值
|
int addPointerForComplex(Node *, void *);
|
||||||
|
|
||||||
Node *findByIndexForNode(List *, unsigned long long);//根据位置查找一个节点
|
Node *findByIndexForNode(List *, unsigned long long);
|
||||||
Node *findByIntForNode(List *, int);//依照特定类型查找一个节点
|
Node *findByIntForNode(List *, int);
|
||||||
Node *findByDoubleForNode(List *, double);//依照特定类型查找一个节点
|
Node *findByDoubleForNode(List *, double);
|
||||||
Node *findByStringForNode(List *, char *);//依照特定类型查找一个节点
|
Node *findByStringForNode(List *, char *);
|
||||||
Node *findByPointerForNode(List *, void *);//依照特定类型查找一个节点
|
Node *findByPointerForNode(List *, void *);
|
||||||
|
|
||||||
List *m_findByIntForNode(List*, int);//根据位置查找所有匹配的节点
|
List *m_findByIntForNode(List*, int);
|
||||||
List *m_findByDoubleForNode(List*, double);//根据位置查找所有匹配的节点
|
List *m_findByDoubleForNode(List*, double);
|
||||||
List *m_findByStringForNode(List*, char *);//根据位置查找所有匹配的节点
|
List *m_findByStringForNode(List*, char *);
|
||||||
List *m_findByPointerForNode(List*, void *);//根据位置查找所有匹配的节点
|
List *m_findByPointerForNode(List*, void *);
|
||||||
|
|
||||||
void printListInfo(List *p_list,int priority);//打印列表的详细信息
|
void printListInfo(List *p_list,int priority);
|
||||||
void printNodeInfo(Node *p_node,int priority);//打印节点的详细信息
|
void printNodeInfo(Node *p_node,int priority);
|
||||||
void printList(List *);//打印列表
|
void printList(List *);
|
||||||
void printNode(Node *p_node);//打印节点
|
void printNode(Node *p_node);
|
||||||
|
|
||||||
int getByIntForNode(Node *);//直接得到节点的值
|
int getByIntForNode(Node *);
|
||||||
double getByDoubleForNode(Node *);//直接得到节点的值
|
double getByDoubleForNode(Node *);
|
||||||
char *getByStringForNode(Node *);//直接得到节点的值
|
char *getByStringForNode(Node *);
|
||||||
void *getByPointerForNode(Node *);//直接得到节点的值
|
void *getByPointerForNode(Node *);
|
||||||
unsigned long long getIndexByNode(List *p_list,Node *p_node);
|
unsigned long long getIndexByNode(List *p_list,Node *p_node);
|
||||||
int listThrough(List *p_list, int (*p_func)(unsigned int type, void *value));//遍历链表并不断调用目标函数。目标函数将接受节点储存值的指针及其类型。
|
int listThrough(List *p_list, int (*p_func)(unsigned int type, void *value));
|
||||||
|
|
||||||
unsigned long long calListMemory(List *);
|
unsigned long long calListMemory(List *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
2
test.c
2
test.c
@ -84,7 +84,7 @@ int stack(void) {
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
//tree();
|
//tree();
|
||||||
init_rand();
|
init_rand();
|
||||||
SID *p_sid = getS_id(LIST_NODE, 3);
|
SID *p_sid = getS_id(LIST_NODE, 1);
|
||||||
char *string = s_idToASCIIString(p_sid);
|
char *string = s_idToASCIIString(p_sid);
|
||||||
SID *t_sid = asciiStringToS_id(string);
|
SID *t_sid = asciiStringToS_id(string);
|
||||||
int if_same = simFitS_id(p_sid, t_sid);
|
int if_same = simFitS_id(p_sid, t_sid);
|
||||||
|
Loading…
Reference in New Issue
Block a user