ASN1C C/C++ Common Runtime  ASN1C v7.5.x
rtxDList.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2021 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];
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
void rtxDListFreeNodes(struct OSCTXT *pctxt, OSRTDList *pList)
OSRTDListNode * tail
Definition: rtxDList.h:67
OSRTDListNode * head
Definition: rtxDList.h:66
OSRTDListNode * rtxDListInsert(struct OSCTXT *pctxt, OSRTDList *pList, OSSIZE idx, void *pData)
struct OSRTDListNode * next
Definition: rtxDList.h:54
OSRTDListNode * rtxDListFindByIndex(const OSRTDList *pList, OSSIZE idx)
void rtxDListFreeNode(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node)
OSRTDListNode * rtxDListFindByData(const OSRTDList *pList, void *data)
void rtxDListInit(OSRTDList *pList)
Definition: rtxDList.h:64
struct OSRTDListNode * prev
Definition: rtxDList.h:55
int rtxDListAppendArray(struct OSCTXT *pctxt, OSRTDList *pList, void *pArray, OSSIZE numElements, OSSIZE elemSize)
void rtxDListFreeAll(struct OSCTXT *pctxt, OSRTDList *pList)
OSRTDListNode * rtxDListAppend(struct OSCTXT *pctxt, OSRTDList *pList, void *pData)
Definition: rtxDList.h:86
OSRTDListNode * rtxDListAppendNode(OSRTDList *pList, OSRTDListNode *pListNode)
int rtxDListAppendArrayCopy(struct OSCTXT *pctxt, OSRTDList *pList, const void *pArray, OSSIZE numElements, OSSIZE elemSize)
int rtxDListToArray(struct OSCTXT *pctxt, OSRTDList *pList, void **ppArray, OSSIZE *pElemCount, OSSIZE elemSize)
Definition: rtxDList.h:52
OSSIZE count
Definition: rtxDList.h:65
OSRTDListNode * rtxDListInsertBefore(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node, void *pData)
OSRTDListNode * rtxDListFindFirstData(const OSRTDList *pList)
int rtxDListToPointerArray(struct OSCTXT *pctxt, OSRTDList *pList, void ***ppArray, OSSIZE *pElemCount)
void rtxDListRemove(OSRTDList *pList, OSRTDListNode *node)
Definition: rtxContext.h:197
Definition: rtxDList.h:72
void * data
Definition: rtxDList.h:53
int rtxDListFindIndexByData(const OSRTDList *pList, void *data)
int rtxDListToUTF8Str(struct OSCTXT *pctxt, OSRTDList *pList, OSUTF8CHAR **ppstr, char sep)
OSRTDListNode * rtxDListAppendCharArray(struct OSCTXT *pctxt, OSRTDList *pList, size_t length, char *pData)
OSRTDListNode * rtxDListInsertAfter(struct OSCTXT *pctxt, OSRTDList *pList, OSRTDListNode *node, void *pData)