ASN1C C/C++ Common Runtime  ASN1C v7.4.x
rtxDList.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2020 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 
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
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)
void rtxDListRemove(OSRTDList *pList, OSRTDListNode *node)
Definition: rtxContext.h:189
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)