slist.h (scrot-1.7.tar.bz2) | : | slist.h (scrot-1.8) | ||
---|---|---|---|---|
/* slist.h | /* slist.h | |||
Copyright 2021 Christopher Nelson <christopher.nelson@languidnights.com> | Copyright 2021 Christopher Nelson <christopher.nelson@languidnights.com> | |||
Copyright 2021 Peter Wu <peterwu@hotmail.com> | ||||
Copyright 2021 Daniel T. Borelli <danieltborelli@gmail.com> | Copyright 2021 Daniel T. Borelli <danieltborelli@gmail.com> | |||
Copyright 2021 Peter Wu <peterwu@hotmail.com> | ||||
Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to | of this software and associated documentation files (the "Software"), to | |||
deal in the Software without restriction, including without limitation the | deal in the Software without restriction, including without limitation the | |||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |||
sell copies of the Software, and to permit persons to whom the Software is | sell copies of the Software, and to permit persons to whom the Software is | |||
furnished to do so, subject to the following conditions: | furnished to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included in | The above copyright notice and this permission notice shall be included in | |||
all copies of the Software and its documentation and acknowledgment shall be | all copies of the Software and its documentation and acknowledgment shall be | |||
skipping to change at line 33 | skipping to change at line 33 | |||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
*/ | */ | |||
#pragma once | #pragma once | |||
#include <sys/queue.h> | #include <sys/queue.h> | |||
typedef struct ScrotListNode { | typedef struct ScrotListNode { | |||
void* data; | void *data; | |||
STAILQ_ENTRY(ScrotListNode) nodes; | STAILQ_ENTRY(ScrotListNode) nodes; | |||
} ScrotListNode; | } ScrotListNode; | |||
typedef STAILQ_HEAD(ScrotLists, ScrotListNode) ScrotList; | typedef STAILQ_HEAD(ScrotLists, ScrotListNode) ScrotList; | |||
#define initializeScrotList(name) \ | #define initializeScrotList(name) \ | |||
ScrotList name = STAILQ_HEAD_INITIALIZER(name); \ | ScrotList name = STAILQ_HEAD_INITIALIZER(name); \ | |||
STAILQ_INIT(&name); | STAILQ_INIT(&name); | |||
#define appendToScrotList(name, newData) do { \ | #define appendToScrotList(name, newData) do { \ | |||
ScrotListNode* node = calloc(1, sizeof(*node)); \ | ScrotListNode *node = calloc(1, sizeof(*node)); \ | |||
node->data = (void*)newData; \ | node->data = (void *)newData; \ | |||
STAILQ_INSERT_TAIL(&name, node, nodes); \ | STAILQ_INSERT_TAIL(&name, node, nodes); \ | |||
} while(0) | } while(0) | |||
#define isEmptyScrotList(name) \ | #define isEmptyScrotList(name) \ | |||
STAILQ_EMPTY(name) | STAILQ_EMPTY(name) | |||
#define forEachScrotList(name, node) \ | #define forEachScrotList(name, node) \ | |||
STAILQ_FOREACH(node, name, nodes) | STAILQ_FOREACH(node, name, nodes) | |||
#define firstScrotList(name) \ | #define firstScrotList(name) \ | |||
STAILQ_FIRST(name) | STAILQ_FIRST(name) | |||
#define nextScrotList(name) \ | #define nextScrotList(name) \ | |||
STAILQ_NEXT(name, nodes); | STAILQ_NEXT(name, nodes); | |||
#define nextAndFreeScrotList(name) do { \ | #define nextAndFreeScrotList(name) do { \ | |||
ScrotListNode* next = nextScrotList(name); \ | ScrotListNode *next = nextScrotList(name); \ | |||
free(name); \ | free(name); \ | |||
name = next; \ | name = next; \ | |||
} while(0) | } while(0) | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |