00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXDLIST_H_
00029 #define _RTXDLIST_H_
00030
00031 #include "rtxsrc/osSysTypes.h"
00032 #include "rtxsrc/rtxExternDefs.h"
00033
00052 typedef struct OSRTDListNode {
00053 void* data;
00054 struct OSRTDListNode* next;
00055 struct OSRTDListNode* prev;
00056 } OSRTDListNode;
00057
00064 typedef struct OSRTDList {
00065 OSUINT32 count;
00066 OSRTDListNode* head;
00067 OSRTDListNode* tail;
00068 } OSRTDList;
00069
00070 struct OSCTXT;
00071
00072 typedef struct OSRTDListBuf {
00073 OSUINT32 n;
00074 OSUINT32 nMax;
00075 OSUINT32 nAll;
00076 OSUINT32 firstSegSz;
00077 size_t elemSize;
00078 OSRTDList tmplist;
00079 void** dataArray;
00080 } OSRTDListBuf;
00081
00082 #ifndef DLISTBUF_SEG
00083 #define DLISTBUF_SEG 16
00084 #endif
00085
00086 typedef struct OSRTDListUTF8StrNode {
00087 OSRTDListNode node;
00088 OSUTF8CHAR utf8chars[1];
00089 } OSRTDListUTF8StrNode;
00090
00091 #ifdef __cplusplus
00092 extern "C" {
00093 #endif
00094
00095
00096
00113 EXTERNRTX void rtxDListInit (OSRTDList* pList);
00114
00134 EXTERNRTX OSRTDListNode* rtxDListAppend
00135 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData);
00136
00137 EXTERNRTX OSRTDListNode* rtxDListAppendNode
00138 (OSRTDList* pList, OSRTDListNode* pListNode);
00139
00159 EXTERNRTX OSRTDListNode* rtxDListInsert
00160 (struct OSCTXT* pctxt, OSRTDList* pList, OSUINT32 index, void* pData);
00161
00162 EXTERNRTX OSRTDListNode* rtxDListInsertNode
00163 (OSRTDList* pList, OSUINT32 index, OSRTDListNode* pListNode);
00164
00184 EXTERNRTX OSRTDListNode* rtxDListInsertBefore
00185 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00186
00206 EXTERNRTX OSRTDListNode* rtxDListInsertAfter
00207 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00208
00222 EXTERNRTX OSRTDListNode*
00223 rtxDListFindByIndex (const OSRTDList* pList, OSUINT32 index);
00224
00235 EXTERNRTX OSRTDListNode*
00236 rtxDListFindByData (const OSRTDList* pList, void* data);
00237
00248 EXTERNRTX int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
00249
00259 EXTERNRTX void rtxDListFreeNode
00260 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
00261
00270 EXTERNRTX void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
00271
00280 EXTERNRTX void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
00281
00291 EXTERNRTX void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
00292
00310 EXTERNRTX int rtxDListToArray
00311 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
00312 OSUINT32* pElemCount, size_t elemSize);
00313
00330 EXTERNRTX int rtxDListAppendArray
00331 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
00332 OSUINT32 numElements, size_t elemSize);
00333
00349 EXTERNRTX int rtxDListAppendArrayCopy
00350 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
00351 OSUINT32 numElements, size_t elemSize);
00352
00368 EXTERNRTX int rtxDListToUTF8Str
00369 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
00373
00374 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
00375
00376 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
00377 *ppnode = (OSRTDListNode*) \
00378 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
00379 if (0 != *ppnode) { \
00380 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
00381 *ppdata = (type*)((*ppnode)->data); \
00382 } else { *ppdata = 0; } \
00383 } while (0)
00384
00385 #define rtxDListAppendData(pctxt,pList,pData) do { \
00386 OSRTDListNode* _node = (OSRTDListNode*) \
00387 (((char*)(pData)) - sizeof(OSRTDListNode)); \
00388 _node->data = pData; \
00389 rtxDListAppendNode (pList, _node); \
00390 } while (0);
00391
00392 #define rtxDListFastInit(pList) do { \
00393 if ((pList) != 0) { \
00394 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
00395 (pList)->count = 0; } \
00396 } while (0)
00397
00398
00399
00400 EXTERNRTX void rtxDListBufInit (OSRTDListBuf* pBuf,
00401 OSUINT32 segSz, void** ppdata, size_t elemSz);
00402
00403 EXTERNRTX int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00404
00405 EXTERNRTX int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00406
00407 #ifdef __cplusplus
00408 }
00409 #endif
00410
00411 #endif