#include <stdio.h>
struct my_struct {
int a, b;
};
#define EVEN_INLIST_GET(Inlist) (& ((Inlist)->even))
#define EVEN_INLIST_CONTAINER_GET(ptr, type) \
((type *)((char *)ptr - offsetof(type, even)))
int
main(void)
{
struct my_struct *d, *cur;
int i;
for (i = 0; i < 100; i++)
{
d = malloc(sizeof(*d));
d->a = i;
d->b = i * 10;
if ((i % 2) == 0)
}
printf("list=%p\n", list);
printf("\ta=%d, b=%d\n", cur->a, cur->b);
printf("list_even=%p\n", list_even);
for (itr = list_even; itr != NULL; itr = itr->next)
{
cur = EVEN_INLIST_CONTAINER_GET(itr, struct my_struct);
printf("\ta=%d, b=%d\n", cur->a, cur->b);
}
itr = list_even;
while (itr)
{
cur = EVEN_INLIST_CONTAINER_GET(itr, struct my_struct);
if ((cur->a % 3) == 0)
itr = next;
}
while (list)
{
struct my_struct);
free(aux);
}
return 0;
}