use typedef
This commit is contained in:
parent
7074e89fd0
commit
5d376a9592
2 changed files with 12 additions and 7 deletions
|
@ -13,16 +13,21 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
struct _queue;
|
||||||
|
struct _queue_node;
|
||||||
|
typedef struct _queue_node queue_node;
|
||||||
|
typedef struct _queue queue;
|
||||||
|
|
||||||
struct _queue_node {
|
struct _queue_node {
|
||||||
void *data;
|
void *data;
|
||||||
struct _queue_node * next;
|
queue * next;
|
||||||
};
|
};
|
||||||
typedef struct _queue_node queue_node;
|
// typedef struct _queue_node queue_node;
|
||||||
|
|
||||||
typedef struct {
|
struct _queue {
|
||||||
queue_node * first;
|
queue_node * first;
|
||||||
queue_node * last;
|
queue_node * last;
|
||||||
} queue;
|
};
|
||||||
|
|
||||||
// create and return the queue
|
// create and return the queue
|
||||||
queue * queue_new(void);
|
queue * queue_new(void);
|
||||||
|
|
|
@ -59,12 +59,12 @@ START_TEST (test_queue)
|
||||||
{
|
{
|
||||||
queue * q = queue_new();
|
queue * q = queue_new();
|
||||||
|
|
||||||
for (short i = 0 ; i < 100 ; i++ ) {
|
for (int i = 0 ; i < 100 ; i++ ) {
|
||||||
queue_push(q, (void*) i);
|
queue_push(q, (void*) i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (short i = 0 ; i < 100 ; i++ ) {
|
for (int i = 0 ; i < 100 ; i++ ) {
|
||||||
short v = (short) queue_pop(q);
|
int v = (int) queue_pop(q);
|
||||||
ck_assert_int_eq(i, v);
|
ck_assert_int_eq(i, v);
|
||||||
}
|
}
|
||||||
queue_free(q);
|
queue_free(q);
|
||||||
|
|
Loading…
Reference in a new issue