Home > Support > Documentation

rtxDList.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2007 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00028 #ifndef _RTXDLIST_H_
00029 #define _RTXDLIST_H_
00030 
00031 #include "rtxsrc/osSysTypes.h"
00032 #include "rtxsrc/rtxExternDefs.h"
00033 #include "rtxsrc/rtxCommonDefs.h"
00034 
00053 typedef struct OSRTDListNode {
00054    void* data;            
00055    struct OSRTDListNode* next; 
00056    struct OSRTDListNode* prev; 
00057 } OSRTDListNode;
00058 
00065 typedef struct OSRTDList {
00066    OSUINT32 count;              
00067    OSRTDListNode* head;         
00068    OSRTDListNode* tail;         
00069 } OSRTDList;
00070 
00071 struct OSCTXT;
00072 
00073 typedef struct OSRTDListBuf {
00074    OSUINT32 n;
00075    OSUINT32 nMax;
00076    OSUINT32 nAll;
00077    OSUINT32 firstSegSz;
00078    size_t elemSize;
00079    OSRTDList tmplist;
00080    void** dataArray;
00081 } OSRTDListBuf;
00082 
00083 #ifndef DLISTBUF_SEG
00084 #define DLISTBUF_SEG 16
00085 #endif
00086 
00087 typedef struct OSRTDListUTF8StrNode {
00088    OSRTDListNode node;
00089    OSUTF8CHAR    utf8chars[1];
00090 } OSRTDListUTF8StrNode;
00091 
00092 #ifdef __cplusplus
00093 extern "C" {
00094 #endif
00095 
00096 /* Doubly-linked list functions */
00097 
00114 EXTERNRTX void rtxDListInit (OSRTDList* pList);
00115 
00135 EXTERNRTX OSRTDListNode* rtxDListAppend 
00136 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData);
00137 
00138 EXTERNRTX OSRTDListNode* rtxDListAppendNode 
00139 (OSRTDList* pList, OSRTDListNode* pListNode);
00140 
00160 EXTERNRTX OSRTDListNode* rtxDListInsert 
00161 (struct OSCTXT* pctxt, OSRTDList* pList, OSUINT32 index, void* pData);
00162 
00163 EXTERNRTX OSRTDListNode* rtxDListInsertNode 
00164 (OSRTDList* pList, OSUINT32 index, OSRTDListNode* pListNode);
00165 
00185 EXTERNRTX OSRTDListNode* rtxDListInsertBefore 
00186 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00187 
00207 EXTERNRTX OSRTDListNode* rtxDListInsertAfter 
00208 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
00209 
00223 EXTERNRTX OSRTDListNode* 
00224 rtxDListFindByIndex (const OSRTDList* pList, OSUINT32 index);
00225 
00236 EXTERNRTX OSRTDListNode* 
00237 rtxDListFindByData (const OSRTDList* pList, void* data);
00238 
00249 EXTERNRTX int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
00250 
00260 EXTERNRTX void rtxDListFreeNode
00261    (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
00262 
00271 EXTERNRTX void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
00272 
00281 EXTERNRTX void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
00282 
00292 EXTERNRTX void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
00293 
00311 EXTERNRTX int rtxDListToArray 
00312 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray, 
00313  OSUINT32* pElemCount, size_t elemSize);
00314 
00331 EXTERNRTX int rtxDListAppendArray 
00332 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray, 
00333  OSUINT32 numElements, size_t elemSize);
00334 
00350 EXTERNRTX int rtxDListAppendArrayCopy 
00351 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray, 
00352  OSUINT32 numElements, size_t elemSize);
00353 
00369 EXTERNRTX int rtxDListToUTF8Str 
00370 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
00374 /* This rounds node size up to a 64-bit boundary to fix alignment issues */
00375 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
00376 
00377 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
00378 *ppnode = (OSRTDListNode*) \
00379 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
00380 if (0 != *ppnode) { \
00381 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
00382 *ppdata = (type*)((*ppnode)->data); \
00383 } else { *ppdata = 0; } \
00384 } while (0)
00385 
00386 #define rtxDListAppendData(pctxt,pList,pData) do { \
00387 OSRTDListNode* _node = (OSRTDListNode*) \
00388 (((char*)(pData)) - sizeof(OSRTDListNode)); \
00389 _node->data = pData; \
00390 rtxDListAppendNode (pList, _node); \
00391 } while (0);
00392 
00393 #define rtxDListFastInit(pList) do { \
00394 if ((pList) != 0) { \
00395 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
00396 (pList)->count = 0; } \
00397 } while (0)
00398 
00399 /* Doubly-linked list buffer functions */
00400 
00401 EXTERNRTX void rtxDListBufInit (OSRTDListBuf* pBuf,
00402    OSUINT32 segSz, void** ppdata, size_t elemSz);
00403 
00404 EXTERNRTX int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00405 
00406 EXTERNRTX int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
00407 
00408 #ifdef __cplusplus
00409 }
00410 #endif
00411 
00412 #endif