XBinder  Version 2.6.x
rtxDList.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
28 #ifndef _RTXDLIST_H_
29 #define _RTXDLIST_H_
30 
31 #include "rtxsrc/osSysTypes.h"
32 #include "rtxsrc/rtxExternDefs.h"
33 #include "rtxsrc/rtxCommonDefs.h"
52 typedef struct OSRTDListNode {
53  void* data;
54  struct OSRTDListNode* next;
55  struct OSRTDListNode* prev;
57 
64 typedef struct OSRTDList {
65  OSSIZE count;
68 } OSRTDList;
69 
70 struct OSCTXT;
71 
72 typedef struct OSRTDListBuf {
73  OSSIZE n;
74  OSSIZE nMax;
75  OSSIZE nAll;
76  OSSIZE firstSegSz;
77  OSSIZE elemSize;
78  OSRTDList tmplist;
79  void** dataArray;
80 } OSRTDListBuf;
81 
82 #ifndef DLISTBUF_SEG
83 #define DLISTBUF_SEG 16
84 #endif
85 
86 typedef struct OSRTDListUTF8StrNode {
87  OSRTDListNode node;
88  OSUTF8CHAR utf8chars[1];
89 } OSRTDListUTF8StrNode;
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 /* Doubly-linked list functions */
96 
113 EXTERNRT void rtxDListInit (OSRTDList* pList);
114 
135 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData);
136 
157 (struct OSCTXT* pctxt, OSRTDList* pList, size_t length, char* pData);
158 
175 (OSRTDList* pList, OSRTDListNode* pListNode);
176 
197 (struct OSCTXT* pctxt, OSRTDList* pList, OSSIZE idx, void* pData);
198 
199 EXTERNRT OSRTDListNode* rtxDListInsertNode
200 (OSRTDList* pList, OSSIZE idx, OSRTDListNode* pListNode);
201 
222 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
223 
244 (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node, void* pData);
245 
259 EXTERNRT OSRTDListNode*
260 rtxDListFindByIndex (const OSRTDList* pList, OSSIZE idx);
261 
272 EXTERNRT OSRTDListNode*
273 rtxDListFindByData (const OSRTDList* pList, void* data);
274 
282 EXTERNRT OSRTDListNode*
283 rtxDListFindFirstData (const OSRTDList* pList);
284 
285 
296 EXTERNRT int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
297 
307 EXTERNRT void rtxDListFreeNode
308  (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
309 
318 EXTERNRT void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
319 
328 EXTERNRT void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
329 
339 EXTERNRT void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
340 
358 EXTERNRT int rtxDListToArray
359 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
360  OSSIZE* pElemCount, OSSIZE elemSize);
361 
378 EXTERNRT int rtxDListAppendArray
379 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
380  OSSIZE numElements, OSSIZE elemSize);
381 
397 EXTERNRT int rtxDListAppendArrayCopy
398 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
399  OSSIZE numElements, OSSIZE elemSize);
400 
416 EXTERNRT int rtxDListToUTF8Str
417 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
418 
419 
420 
421 typedef int (*PEqualsFunc) (const void* a, const void* b,
422  const void* sortCtxt);
423 
424 EXTERNRT OSRTDListNode* rtxDListInsertSorted
425 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData, PEqualsFunc equalsFunc,
426  void* sortCtxt);
427 
428 EXTERNRT OSRTDListNode* rtxDListInsertNodeSorted
429 (OSRTDList* pList, OSRTDListNode* pListNode, PEqualsFunc equalsFunc,
430  void* sortCtxt);
431 
435 #if defined(_MSC_VER)
436 /* this disables 'conditional expression is constant' warnings */
437 /* caused by using do { ... } while(0) in defines. */
438 #pragma warning(disable: 4127)
439 #endif
440 
441 /* This rounds node size up to a 64-bit boundary to fix alignment issues */
442 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
443 
444 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
445 *ppnode = (OSRTDListNode*) \
446 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
447 if (0 != *ppnode) { \
448 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
449 *ppdata = (type*)((*ppnode)->data); \
450 } else { *ppdata = 0; } \
451 } while (0)
452 
453 #define rtxDListAppendData(pctxt,pList,pData) do { \
454  rtxDListAppend(pctxt,pList,pData); \
455 } while(0);
456 
457 /* Use function rtxDListInit instead. This macro reportedly caused problems
458  * in some cases. */
459 #define rtxDListFastInit(pList) do { \
460 if ((pList) != 0) { \
461 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
462 (pList)->count = 0; } \
463 } while (0)
464 
465 #define rtxDListFreeTailNode(pctxt,pList) \
466 rtxDListFreeNode(pctxt,pList,(pList)->tail)
467 
468 #define rtxDListFreeHeadNode(pctxt,pList) \
469 rtxDListFreeNode(pctxt,pList,(pList)->head)
470 
471 /* Doubly-linked list buffer functions */
472 
473 EXTERNRT void rtxDListBufInit (OSRTDListBuf* pBuf,
474  OSSIZE segSz, void** ppdata, OSSIZE elemSz);
475 
476 EXTERNRT int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
477 
478 EXTERNRT int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
479 
480 #ifdef __cplusplus
481 }
482 #endif
483 
484 #endif
EXTERNRT OSRTDListNode * rtxDListAppendNode(OSRTDList *pList, OSRTDListNode *pListNode)
This function appends an OSRTDListNode to the linked list structure.
OSRTDListNode * tail
Pointer to last entry in list.
Definition: rtxDList.h:67
OSRTDListNode * head
Pointer to first entry in list.
Definition: rtxDList.h:66
EXTERNRT OSRTDListNode * rtxDListInsertAfter(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node, void *pData)
This function inserts an item into the linked list structure after the specified element.
EXTERNRT void rtxDListFreeNode(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node)
This function will remove the given node from the list and free memory.
EXTERNRT void rtxDListFreeNodes(struct OSCTXT *pctxt, OSRTDList *pList)
This function will free all of the dynamic memory used to hold the list node pointers.
EXTERNRT OSRTDListNode * rtxDListInsertBefore(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node, void *pData)
This function inserts an item into the linked list structure before the specified element...
EXTERNRT OSRTDListNode * rtxDListAppendCharArray(struct OSCTXT *pctxt, OSRTDList *pList, size_t length, char *pData)
This function appends an item to the linked list structure.
EXTERNRT int rtxDListAppendArrayCopy(struct OSCTXT *pctxt, OSRTDList *pList, const void *pArray, OSSIZE numElements, OSSIZE elemSize)
This function appends a copy of each item in the given array to a doubly linked list structure...
struct OSRTDListNode * next
Pointer to next node in list.
Definition: rtxDList.h:54
EXTERNRT void rtxDListFreeAll(struct OSCTXT *pctxt, OSRTDList *pList)
This function will free all of the dynamic memory used to hold the list node pointers and the data it...
This is the main list structure.
Definition: rtxDList.h:64
struct OSRTDListNode * prev
Pointer to previous node in list.
Definition: rtxDList.h:55
EXTERNRT void rtxDListInit(OSRTDList *pList)
This function initializes a doubly linked list structure.
EXTERNRT OSRTDListNode * rtxDListInsert(struct OSCTXT *pctxt, OSRTDList *pList, OSSIZE idx, void *pData)
This function inserts an item into the linked list structure.
This structure is used to hold a single data item within the list.
Definition: rtxDList.h:52
OSSIZE count
Count of items in the list.
Definition: rtxDList.h:65
EXTERNRT OSRTDListNode * rtxDListFindByIndex(const OSRTDList *pList, OSSIZE idx)
This function will return the node pointer of the indexed entry in the list.
EXTERNRT OSRTDListNode * rtxDListAppend(struct OSCTXT *pctxt, OSRTDList *pList, void *pData)
This function appends an item to the linked list structure.
EXTERNRT int rtxDListFindIndexByData(const OSRTDList *pList, void *data)
This function will return the index of the given data item within the list or -1 if the item is not f...
EXTERNRT OSRTDListNode * rtxDListFindByData(const OSRTDList *pList, void *data)
This function will return the node pointer of the given data item within the list or NULL if the item...
EXTERNRT int rtxDListToUTF8Str(struct OSCTXT *pctxt, OSRTDList *pList, OSUTF8CHAR **ppstr, char sep)
This function concatanates all of the components in the given list to form a UTF-8 string...
EXTERNRT int rtxDListAppendArray(struct OSCTXT *pctxt, OSRTDList *pList, void *pArray, OSSIZE numElements, OSSIZE elemSize)
This function appends pointers to items in the given array to a doubly linked list structure...
EXTERNRT void rtxDListRemove(OSRTDList *pList, OSRTDListNode *node)
This function will remove the given node from the list.
Run-time context structure.
Definition: rtxContext.h:185
Common definitions of external function modifiers used to define the scope of functions used in DLL's...
EXTERNRT int rtxDListToArray(struct OSCTXT *pctxt, OSRTDList *pList, void **ppArray, OSSIZE *pElemCount, OSSIZE elemSize)
This function converts a doubly linked list to an array.
void * data
Pointer to list data item.
Definition: rtxDList.h:53
EXTERNRT OSRTDListNode * rtxDListFindFirstData(const OSRTDList *pList)
This function will return the node pointer of the first non-null data item within the list or NULL if...