请问该代码哪里有逻辑错误

#include"stdio.h"

#include"stdlib.h"

typedef struct node {

int data;
struct node *prior;

struct node *next;

} node;

int inlist(node **l) {

l = (node)malloc(sizeof(node));

(*l)->next = NULL;

(*l)->prior = NULL;

return 0;

}

int csh(node **l) {

*l = NULL;

return 0;

}

int insert(node *l, int i, int e) {

node *p,*q; int j;

p=l; printf(" %d ", p);

printf("%d\n",i);

for (j = 0; p->next && j < i; j++){p = p->next;}

if (j == i) {

node s = (node)malloc(sizeof(node));

s->data = e;

s->prior = p->prior;

p->prior->next = s;

s->next = p;

p->prior=s;

}

return 0;

}

int deletenode(node **l, int i) {

node *p; int j;

p = (node*)malloc(sizeof(node));

p = *l;

for (j = 0; p->next && j < i; j++)p = p->next;

if (j == i) {

node q = (node)malloc(sizeof(node));

q = p;

p->prior->next = p->next;

if (p->next)

p->next->prior = p->prior;

free(q);

}

return 0;

}

void creat_h(node **l, int n) {

node *q