TAILQ_HEAD 에 대해서?
안녕하세요? 제가 소스를 보고 있는데 위와 같은 함수를 만나서 어려움을 겪고 있습니다. 리눅스 환경에서 man queue 로 살펴보니. 다음과 같은
TAIL QUEUE EXAMPLE
TAILQ_HEAD(tailhead, entry) head;
struct tailhead *headp; /* Tail queue head. */
struct entry {
...
TAILQ_ENTRY(entry) entries; /* Tail queue. */
...
} *n1, *n2, *np;
TAILQ_INIT(&head); /* Initialize the queue. */
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
TAILQ_INSERT_HEAD(&head, n1, entries);
n1 = malloc(sizeof(struct entry)); /* Insert at the tail. */
TAILQ_INSERT_TAIL(&head, n1, entries);
설명을 볼수가 있었습니다.
여기서, TAILQ_HEAD(tailhead, entry) head; 도대체 tailhead, entry, head 가 의미하는 바를 알 수가 없군요.. 큐에 구조체 넣어주고 포인터로 연결하겠지? 라는 생각을 해봤는데.. 부족하군요..혹시, 예제 비슷한것이 있으면 부탁좀 드리겠습니다..
ps. 많은 분들의 관심 부탁드립니다.
BSD TAILQ 를 쓰시려는가 보군요.약간 헷갈릴 소지가 있습니
BSD TAILQ 를 쓰시려는가 보군요.
약간 헷갈릴 소지가 있습니다. 전부 매크로로 되어 있고,
사실 매크로의 인자도 타입의 이름등이거든요.
자세히 알고 싶으시면, usr/include/sys/queue.h
를 참조하시면 되구요.
예제를 원하신다고 했는데, 지금 올리신 그게 바로 예제입니다.--;;
#include <sys/queue.h>
하시고 위에 TAILQ EXAMPLE 어쩌고를 지우시면 바로 compile 될 겁니다.
질문하신 tailhead, entry, head의 관계는 TAILQ_HEAD Macro를
한번 보시면 바로 이해하실 수 있으실거라고 봅니다..[/code]
I thought what I'd do was,
I'd pretend I was one of those deaf-mutes.. or should I?
libevent에서 보시면tailQ를 사용합니다.소스 열어
libevent에서 보시면
tailQ를 사용합니다.
소스 열어서 그것도 참고해보세요
답변 감사드립니다.
드디어, 어떻게 돌아가는지 대충 아랐습니다... 온통 매크로라서 헤멨는데..
지금은 여러분들의 답글로 해결할 수 있었습니다. 리플 달아 주신분들께
감사의 말씀 전해 드립니다.
TAILQ 예제甲
http://blog.unx.ca/2006/08/tailq-example.html
개학할 때는 아직 아닌 것 같은데.. 묘하게 끌리는
개학할 때는 아직 아닌 것 같은데.. 묘하게 끌리는 질문들이 많네요.
언제나 F 를 지향하며, http://kldp.org/files/qqq.c.txt
댓글 달기