Use stylesheet transformations to output HTML, for example
This commit is contained in:
16
src/queue.h
16
src/queue.h
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
#ifndef _QUEUE_H
|
||||
#define _QUEUE_H
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DEFINE_QUEUE(T, N) \
|
||||
@@ -45,6 +46,13 @@ typedef struct { \
|
||||
#define NEW_QUEUE(T, N) \
|
||||
T N = (T) { .length = 0, .head = NULL, .tail = NULL }
|
||||
|
||||
/* WARNING: this is probably not what you want -- see DESTROY_QUEUE below */
|
||||
#define REINIT_QUEUE(N) { \
|
||||
(N).length = 0; \
|
||||
(N).head = NULL; \
|
||||
(N).tail = NULL; \
|
||||
}
|
||||
|
||||
#define APPEND_QUEUE(T, Q, E) { \
|
||||
struct _##T##Node* n = (struct _##T##Node*)malloc(sizeof(struct _##T##Node)); \
|
||||
if (!n) { perror ("Could not allocate space for new queue element."); exit(1); } \
|
||||
@@ -56,7 +64,7 @@ typedef struct { \
|
||||
(Q).length++; \
|
||||
}
|
||||
|
||||
#define QUEUE_LENGTH(Q) Q.length
|
||||
#define QUEUE_LENGTH(Q) (Q).length
|
||||
|
||||
#define FOREACH_QUEUE(T, Q, N) { \
|
||||
struct _##T##Node* N = NULL; \
|
||||
@@ -89,10 +97,10 @@ typedef struct { \
|
||||
|
||||
#define QUEUE_TO_ARRAY(QT, Q, T, DST) { \
|
||||
int i = 0; \
|
||||
DST = (T*)calloc(Q.length,sizeof(T)); \
|
||||
if (!DST) { perror("Could not allocate space for array."); exit(1); } \
|
||||
(DST) = (T*)calloc((Q).length,sizeof(T)); \
|
||||
if (!(DST)) { perror("Could not allocate space for array."); exit(1); } \
|
||||
FOREACH_QUEUE(QT, Q, ptr) \
|
||||
DST[i++] = ptr->data; \
|
||||
(DST)[i++] = ptr->data; \
|
||||
FOREACH_QUEUE_END; \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user