XBinder  Version 2.9.x
rtxDList.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2022 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 
361 EXTERNRT int rtxDListToArray
362 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
363  OSSIZE* pElemCount, OSSIZE elemSize);
364 
365 
383 EXTERNRT int rtxDListToPointerArray
384 (struct OSCTXT* pctxt, OSRTDList* pList, void*** ppArray,
385  OSSIZE* pElemCount);
386 
403 EXTERNRT int rtxDListAppendArray
404 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
405  OSSIZE numElements, OSSIZE elemSize);
406 
422 EXTERNRT int rtxDListAppendArrayCopy
423 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
424  OSSIZE numElements, OSSIZE elemSize);
425 
441 EXTERNRT int rtxDListToUTF8Str
442 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
443 
444 
445 
446 typedef int (*PEqualsFunc) (const void* a, const void* b,
447  const void* sortCtxt);
448 
449 EXTERNRT OSRTDListNode* rtxDListInsertSorted
450 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData, PEqualsFunc equalsFunc,
451  void* sortCtxt);
452 
453 EXTERNRT OSRTDListNode* rtxDListInsertNodeSorted
454 (OSRTDList* pList, OSRTDListNode* pListNode, PEqualsFunc equalsFunc,
455  void* sortCtxt);
456 
460 #if defined(_MSC_VER)
461 /* this disables 'conditional expression is constant' warnings */
462 /* caused by using do { ... } while(0) in defines. */
463 #pragma warning(disable: 4127)
464 #endif
465 
466 /* This rounds node size up to a 64-bit boundary to fix alignment issues */
467 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
468 
469 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
470 *ppnode = (OSRTDListNode*) \
471 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
472 if (0 != *ppnode) { \
473 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
474 *ppdata = (type*)((*ppnode)->data); \
475 } else { *ppdata = 0; } \
476 } while (0)
477 
478 #define rtxDListAppendData(pctxt,pList,pData) do { \
479  rtxDListAppend(pctxt,pList,pData); \
480 } while(0);
481 
482 /* Use function rtxDListInit instead. This macro reportedly caused problems
483  * in some cases. */
484 #define rtxDListFastInit(pList) do { \
485 if ((pList) != 0) { \
486 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
487 (pList)->count = 0; } \
488 } while (0)
489 
490 #define rtxDListFreeTailNode(pctxt,pList) \
491 rtxDListFreeNode(pctxt,pList,(pList)->tail)
492 
493 #define rtxDListFreeHeadNode(pctxt,pList) \
494 rtxDListFreeNode(pctxt,pList,(pList)->head)
495 
496 /* Doubly-linked list buffer functions */
497 
498 EXTERNRT void rtxDListBufInit (OSRTDListBuf* pBuf,
499  OSSIZE segSz, void** ppdata, OSSIZE elemSz);
500 
501 EXTERNRT int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
502 
503 EXTERNRT int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
504 
505 #ifdef __cplusplus
506 }
507 #endif
508 
509 #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 rtxDListToPointerArray(struct OSCTXT *pctxt, OSRTDList *pList, void ***ppArray, OSSIZE *pElemCount)
This function converts a doubly linked list of *T to a dynamically (or pre-allocated) array of *T...
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:198
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 of *T to a dynamically (or pre-allocated) array of T...
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...