ASN1C C/C++ Common Runtime  ASN1C v7.2.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];
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 
285 EXTERNRT int rtxDListFindIndexByData (const OSRTDList* pList, void* data);
286 
296 EXTERNRT void rtxDListFreeNode
297  (struct OSCTXT* pctxt, OSRTDList* pList, OSRTDListNode* node);
298 
307 EXTERNRT void rtxDListRemove (OSRTDList* pList, OSRTDListNode* node);
308 
317 EXTERNRT void rtxDListFreeNodes (struct OSCTXT* pctxt, OSRTDList* pList);
318 
328 EXTERNRT void rtxDListFreeAll (struct OSCTXT* pctxt, OSRTDList* pList);
329 
347 EXTERNRT int rtxDListToArray
348 (struct OSCTXT* pctxt, OSRTDList* pList, void** ppArray,
349  OSSIZE* pElemCount, OSSIZE elemSize);
350 
367 EXTERNRT int rtxDListAppendArray
368 (struct OSCTXT* pctxt, OSRTDList* pList, void* pArray,
369  OSSIZE numElements, OSSIZE elemSize);
370 
386 EXTERNRT int rtxDListAppendArrayCopy
387 (struct OSCTXT* pctxt, OSRTDList* pList, const void* pArray,
388  OSSIZE numElements, OSSIZE elemSize);
389 
405 EXTERNRT int rtxDListToUTF8Str
406 (struct OSCTXT* pctxt, OSRTDList* pList, OSUTF8CHAR** ppstr, char sep);
407 
408 
409 
410 typedef int (*PEqualsFunc) (const void* a, const void* b,
411  const void* sortCtxt);
412 
413 EXTERNRT OSRTDListNode* rtxDListInsertSorted
414 (struct OSCTXT* pctxt, OSRTDList* pList, void* pData, PEqualsFunc equalsFunc,
415  void* sortCtxt);
416 
417 EXTERNRT OSRTDListNode* rtxDListInsertNodeSorted
418 (OSRTDList* pList, OSRTDListNode* pListNode, PEqualsFunc equalsFunc,
419  void* sortCtxt);
420 
424 #if defined(_MSC_VER)
425 /* this disables 'conditional expression is constant' warnings */
426 /* caused by using do { ... } while(0) in defines. */
427 #pragma warning(disable: 4127)
428 #endif
429 
430 /* This rounds node size up to a 64-bit boundary to fix alignment issues */
431 #define OSRTDLISTNODESIZE ((sizeof(OSRTDListNode)+7)&(~7))
432 
433 #define rtxDListAllocNodeAndData(pctxt,type,ppnode,ppdata) do { \
434 *ppnode = (OSRTDListNode*) \
435 rtxMemAlloc (pctxt, sizeof(type)+OSRTDLISTNODESIZE); \
436 if (0 != *ppnode) { \
437 (*ppnode)->data = (void*)((char*)(*ppnode)+OSRTDLISTNODESIZE); \
438 *ppdata = (type*)((*ppnode)->data); \
439 } else { *ppdata = 0; } \
440 } while (0)
441 
442 #define rtxDListAppendData(pctxt,pList,pData) do { \
443  rtxDListAppend(pctxt,pList,pData); \
444 } while(0);
445 
446 /* Use function rtxDListInit instead. This macro reportedly caused problems
447  * in some cases. */
448 #define rtxDListFastInit(pList) do { \
449 if ((pList) != 0) { \
450 (pList)->head = (pList)->tail = (OSRTDListNode*) 0; \
451 (pList)->count = 0; } \
452 } while (0)
453 
454 #define rtxDListFreeTailNode(pctxt,pList) \
455 rtxDListFreeNode(pctxt,pList,(pList)->tail)
456 
457 #define rtxDListFreeHeadNode(pctxt,pList) \
458 rtxDListFreeNode(pctxt,pList,(pList)->head)
459 
460 /* Doubly-linked list buffer functions */
461 
462 EXTERNRT void rtxDListBufInit (OSRTDListBuf* pBuf,
463  OSSIZE segSz, void** ppdata, OSSIZE elemSz);
464 
465 EXTERNRT int rtxDListBufExpand (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
466 
467 EXTERNRT int rtxDListBufToArray (struct OSCTXT* pctxt, OSRTDListBuf* pBuf);
468 
469 #ifdef __cplusplus
470 }
471 #endif
472 
473 #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)
void rtxDListRemove(OSRTDList *pList, OSRTDListNode *node)
Definition: rtxContext.h:185
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)