Qual o problema com as implementações a seguir para a função queueInit()?
typedef struct queueNode QueueNode; typedef struct queueNode* Link; struct queueNode { Item conteudo; Link prox; }; static Link inicio; void queueInit() /* implementacao 1 */ { inicio = (Link) mallocSafe(sizeof *inicio); inicio = NULL; } void queueInit(Link inicio) /* implementacao 2 */ { inicio = (Link) mallocSafe(sizeof *inicio); inicio->prox = NULL; } Link queueInit() /* implementacao 3 */ { QueueNode inicio; inicio.prox = NULL; return &inicio; } Link queueInit() /* implementacao 4 */ { Link inicio = mallocSafe(sizeof *inicio); inicio->prox = NULL; return inicio; }
/* implementacao 5 */ typedef struct queueNode* Link; struct queueNode { Item conteudo; Link prox; }; struct queue { /* aqui esta especificado o que e' */ Link inicio; /* uma fila: dois apontadores para struct queueNode */ Link fim; }; typedef struct queue *Queue; Queue queueInit(int maxN) { Queue q = mallocSafe(sizeof *q); q->inicio = mallocSafe(sizeof(struct queueNode)); q->fim = mallocSafe(sizeof(struct queueNode)); return q; }