temp->prev = q->rear; // allocate a new array for our new item #if NODE_TYPE == LINKED if (!q->rear->next) { q->rear->next = malloc(sizeof(*q->rear->next)); } else { abort(); } // update rear->next to point to the new item q->rear->next = temp; // update rear to point to the rear->next, which is the item we just added, updating the pointer rear from our old item to our new item q->rear = q->rear->next; #elif NODE_TYPE == TREE struct QNode * p = q->rear; if (type == NODE_TYPE_BRANCH_CHOICE_START) { while(p) { if (p->type == NODE_TYPE_BRANCH_START) { puts("FOUND BRANCH START"); q->rear = p; break; } if (p->prev) p = p->prev; else p = NULL; } } // allocate a new array for our new item if (!q->rear->branch) { q->rear->branch_count = 1; q->rear->branch = malloc(sizeof(struct QNode)*q->rear->branch_count); } else { q->rear->branch_count++; q->rear->branch = realloc(q->rear->branch, sizeof(struct QNode)*q->rear->branch_count); } // update rear->next to point to the new item q->rear->branch[q->rear->branch_count-1] = temp; // update rear to point to the rear->next, which is the item we just added, updating the pointer rear from our old item to our new item q->rear = q->rear->branch[q->rear->branch_count-1]; #endif