tlist
This commit is contained in:
parent
39bf54bba5
commit
40ba2bd866
|
@ -16,7 +16,7 @@
|
|||
#ifndef _TD_UTIL_ENCODE_H_
|
||||
#define _TD_UTIL_ENCODE_H_
|
||||
|
||||
#include "freelist.h"
|
||||
#include "tfreelist.h"
|
||||
#include "tcoding.h"
|
||||
#include "tmacro.h"
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#ifndef _TD_UTIL_FREELIST_H_
|
||||
#define _TD_UTIL_FREELIST_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -12,8 +12,10 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef _TD_UTIL_LIST_H
|
||||
#define _TD_UTIL_LIST_H
|
||||
#ifndef _TD_UTIL_LIST_H_
|
||||
#define _TD_UTIL_LIST_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -28,7 +30,7 @@ extern "C" {
|
|||
#define TD_SLIST(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *sl_head_; \
|
||||
int sl_neles_; \
|
||||
int32_t sl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_SLIST_HEAD(sl) ((sl)->sl_head_)
|
||||
|
@ -79,7 +81,7 @@ extern "C" {
|
|||
struct { \
|
||||
struct TYPE *dl_head_; \
|
||||
struct TYPE *dl_tail_; \
|
||||
int dl_neles_; \
|
||||
int32_t dl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_DLIST_NODE_PREV(dln) ((dln)->dl_prev_)
|
||||
|
@ -200,11 +202,11 @@ typedef struct SListNode {
|
|||
|
||||
typedef struct {
|
||||
TD_DLIST(SListNode);
|
||||
int eleSize;
|
||||
int32_t eleSize;
|
||||
} SList;
|
||||
|
||||
typedef struct {
|
||||
SListNode * next;
|
||||
SListNode *next;
|
||||
TD_LIST_DIRECTION_T direction;
|
||||
} SListIter;
|
||||
|
||||
|
@ -215,14 +217,14 @@ typedef struct {
|
|||
#define isListEmpty(l) (TD_DLIST_NELES(l) == 0)
|
||||
#define listNodeFree(n) free(n)
|
||||
|
||||
void tdListInit(SList *list, int eleSize);
|
||||
void tdListInit(SList *list, int32_t eleSize);
|
||||
void tdListEmpty(SList *list);
|
||||
SList * tdListNew(int eleSize);
|
||||
void * tdListFree(SList *list);
|
||||
SList *tdListNew(int32_t eleSize);
|
||||
void *tdListFree(SList *list);
|
||||
void tdListPrependNode(SList *list, SListNode *node);
|
||||
void tdListAppendNode(SList *list, SListNode *node);
|
||||
int tdListPrepend(SList *list, void *data);
|
||||
int tdListAppend(SList *list, void *data);
|
||||
int32_t tdListPrepend(SList *list, void *data);
|
||||
int32_t tdListAppend(SList *list, void *data);
|
||||
SListNode *tdListPopHead(SList *list);
|
||||
SListNode *tdListPopTail(SList *list);
|
||||
SListNode *tdListGetHead(SList *list);
|
||||
|
@ -239,4 +241,4 @@ SListNode *tdListNext(SListIter *pIter);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_LIST_H*/
|
||||
#endif /*_TD_UTIL_LIST_H_*/
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_INT_H_
|
||||
#define _TD_UTIL_INT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_INT_H_*/
|
|
@ -13,15 +13,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tlist.h"
|
||||
#include "os.h"
|
||||
|
||||
void tdListInit(SList *list, int eleSize) {
|
||||
void tdListInit(SList *list, int32_t eleSize) {
|
||||
TD_DLIST_INIT(list);
|
||||
listEleSize(list) = eleSize;
|
||||
}
|
||||
|
||||
SList *tdListNew(int eleSize) {
|
||||
SList *tdListNew(int32_t eleSize) {
|
||||
SList *list = (SList *)malloc(sizeof(SList));
|
||||
if (list == NULL) return NULL;
|
||||
|
||||
|
@ -50,7 +50,7 @@ void tdListPrependNode(SList *list, SListNode *node) { TD_DLIST_PREPEND(list, no
|
|||
|
||||
void tdListAppendNode(SList *list, SListNode *node) { TD_DLIST_APPEND(list, node); }
|
||||
|
||||
int tdListPrepend(SList *list, void *data) {
|
||||
int32_t tdListPrepend(SList *list, void *data) {
|
||||
SListNode *node = (SListNode *)malloc(sizeof(SListNode) + list->eleSize);
|
||||
if (node == NULL) return -1;
|
||||
|
||||
|
@ -60,7 +60,7 @@ int tdListPrepend(SList *list, void *data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdListAppend(SList *list, void *data) {
|
||||
int32_t tdListAppend(SList *list, void *data) {
|
||||
SListNode *node = (SListNode *)calloc(1, sizeof(SListNode) + list->eleSize);
|
||||
if (node == NULL) return -1;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "freelist.h"
|
||||
#include "tfreelist.h"
|
||||
|
||||
TEST(TD_UTIL_FREELIST_TEST, simple_test) {
|
||||
SFreeList fl;
|
||||
|
|
Loading…
Reference in New Issue