RetroZilla/security/nss/lib/jar/jar-ds.h

79 lines
1.6 KiB
C
Raw Normal View History

2018-05-04 16:08:28 +02:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2015-10-21 05:03:22 +02:00
#ifndef __JAR_DS_h_
#define __JAR_DS_h_
/* Typedefs */
typedef struct ZZLinkStr ZZLink;
typedef struct ZZListStr ZZList;
/*
** Circular linked list. Each link contains a pointer to the object that
** is actually in the list.
2018-05-04 16:08:28 +02:00
*/
struct ZZLinkStr {
2015-10-21 05:03:22 +02:00
ZZLink *next;
ZZLink *prev;
JAR_Item *thing;
};
2018-05-04 16:08:28 +02:00
struct ZZListStr {
2015-10-21 05:03:22 +02:00
ZZLink link;
};
2018-05-04 16:08:28 +02:00
#define ZZ_InitList(lst) \
{ \
2015-10-21 05:03:22 +02:00
(lst)->link.next = &(lst)->link; \
(lst)->link.prev = &(lst)->link; \
2018-05-04 16:08:28 +02:00
(lst)->link.thing = 0; \
2015-10-21 05:03:22 +02:00
}
2018-05-04 16:08:28 +02:00
#define ZZ_ListEmpty(lst) ((lst)->link.next == &(lst)->link)
2015-10-21 05:03:22 +02:00
2018-05-04 16:08:28 +02:00
#define ZZ_ListHead(lst) ((lst)->link.next)
2015-10-21 05:03:22 +02:00
2018-05-04 16:08:28 +02:00
#define ZZ_ListTail(lst) ((lst)->link.prev)
2015-10-21 05:03:22 +02:00
2018-05-04 16:08:28 +02:00
#define ZZ_ListIterDone(lst,lnk) ((lnk) == &(lst)->link)
2015-10-21 05:03:22 +02:00
#define ZZ_AppendLink(lst,lnk) \
2018-05-04 16:08:28 +02:00
{ \
(lnk)->next = &(lst)->link; \
2015-10-21 05:03:22 +02:00
(lnk)->prev = (lst)->link.prev; \
(lst)->link.prev->next = (lnk); \
2018-05-04 16:08:28 +02:00
(lst)->link.prev = (lnk); \
2015-10-21 05:03:22 +02:00
}
#define ZZ_InsertLink(lst,lnk) \
2018-05-04 16:08:28 +02:00
{ \
2015-10-21 05:03:22 +02:00
(lnk)->next = (lst)->link.next; \
2018-05-04 16:08:28 +02:00
(lnk)->prev = &(lst)->link; \
2015-10-21 05:03:22 +02:00
(lst)->link.next->prev = (lnk); \
2018-05-04 16:08:28 +02:00
(lst)->link.next = (lnk); \
2015-10-21 05:03:22 +02:00
}
2018-05-04 16:08:28 +02:00
#define ZZ_RemoveLink(lnk) \
{ \
2015-10-21 05:03:22 +02:00
(lnk)->next->prev = (lnk)->prev; \
(lnk)->prev->next = (lnk)->next; \
2018-05-04 16:08:28 +02:00
(lnk)->next = 0; \
(lnk)->prev = 0; \
2015-10-21 05:03:22 +02:00
}
2018-05-04 16:08:28 +02:00
extern ZZLink *
ZZ_NewLink(JAR_Item *thing);
extern void
ZZ_DestroyLink(ZZLink *link);
extern ZZList *
ZZ_NewList(void);
extern void
ZZ_DestroyList(ZZList *list);
2015-10-21 05:03:22 +02:00
#endif /* __JAR_DS_h_ */