diff options
-rw-r--r-- | tbl_qcmd.c | 87 | ||||
-rw-r--r-- | tbl_qcmd.h | 9 |
2 files changed, 95 insertions, 1 deletions
@@ -120,6 +120,52 @@ int tbl_exec_print(tble_exec *tble, int flags) return 0; } +int tbl_exec_tbl_free(tbl_exec *tbl) +{ + int i; + + if (tbl == NULL) + { + return -1; + } + + if (tbl->cmd != NULL) + { + for (i=0;i<tbl->size;i++) + { + tbl_exec_tel_free(tbl->cmd[i]); + } + free(tbl->cmd); + } + + free(tbl); + + return 0; +} + + +int tbl_exec_tel_free(tble_exec *tble) +{ + int i; + + if (tble == NULL) + { + return -1; + } + + free(tble->name); + tble->name = NULL; + + free(tble->cmd); + tble->cmd = NULL; + + free(tble); + tble = NULL; + + return 0; +} + + int tbl_exec_print_tbl(tbl_exec *tbl, int flags) { int i; @@ -358,6 +404,7 @@ int tbl_cmd_param_print(tble_cmd_param *param) if (param == NULL) return -1; + printf("PARAM "); printf("ID:[%d] ", param->id); printf("QID:[%d] ", param->qid); printf("OUT_Q:[%d] ", param->out_q); @@ -395,7 +442,11 @@ int tbl_cmd_resp_free(tble_cmd_resp *resp) return -1; } + free(resp->resp); + resp->resp = NULL; + free(resp); + resp = NULL; return 0; } @@ -405,6 +456,7 @@ int tbl_cmd_resp_print(tble_cmd_resp *resp) if (resp == NULL) return -1; + printf("RESP "); printf("ID:[%d] ", resp->id); printf("QID:[%d] ", resp->qid); printf("TYPE:[%d] ", resp->type); @@ -499,14 +551,47 @@ int tbl_qcmd_print_tbl(tbl_qcmd *tbl, int flags) } -int tbl_qcmd_destroy_cmd(tble_qcmd *tbl) +int tbl_qcmd_destroy_cmd(tble_qcmd *tble) { + if (tble == NULL ) + { + return -1; + } + + free(tble->cmd); + tble->cmd = NULL; + + free(tble->param); + tble->param = NULL; + + free(tble); + tble=NULL; + return 0; } int tbl_qcmd_destroy_table(tbl_qcmd *tbl) { + int i; + + if (tbl == NULL) + { + return -1; + } + + for (i=0; i<tbl->size;i++) + { + if (tbl->cmd[i] != NULL) + tbl_qcmd_destroy_cmd(tbl->cmd[i]); + } + + free(tbl->cmd); + tbl->cmd = NULL; + + free(tbl); + tbl = NULL; + return 0; } @@ -111,6 +111,7 @@ typedef struct tble_cmd_param char *param; } tble_cmd_param; + /* Fields: */ @@ -123,6 +124,11 @@ typedef struct tble_cmd_resp char *resp; } tble_cmd_resp; +#define TBL_RSP_NONE 0 //default value +#define TBL_RSP_NORESP 1 //no response +#define TBL_RSP_ERR 2 //error happened with thread +#define TBL_RSP_OK 4 //response + /* create exec command, used to add to table Input: @@ -180,6 +186,9 @@ tble_exec *tbl_exec_search_cmd(tbl_exec *tbl, tble_qcmd *cmd); int tbl_exec_print(tble_exec *tble, int flags); +int tbl_exec_tbl_free(tbl_exec *tbl); +int tbl_exec_tel_free(tble_exec *tble); + /* print all entries in table Input: |