|
@@ -26,12 +26,20 @@
|
|
void
|
|
void
|
|
insque (void *elem, void *prev)
|
|
insque (void *elem, void *prev)
|
|
{
|
|
{
|
|
- struct qelem *next = ((struct qelem *) prev)->q_forw;
|
|
+ if (prev == NULL)
|
|
- ((struct qelem *) prev)->q_forw = (struct qelem *) elem;
|
|
+ {
|
|
- if (next != NULL)
|
|
+ ((struct qelem *) elem)->q_forw = NULL;
|
|
- next->q_back = (struct qelem *) elem;
|
|
+ ((struct qelem *) elem)->q_back = NULL;
|
|
- ((struct qelem *) elem)->q_forw = next;
|
|
+ }
|
|
- ((struct qelem *) elem)->q_back = (struct qelem *) prev;
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ struct qelem *next = ((struct qelem *) prev)->q_forw;
|
|
|
|
+ ((struct qelem *) prev)->q_forw = (struct qelem *) elem;
|
|
|
|
+ if (next != NULL)
|
|
|
|
+ next->q_back = (struct qelem *) elem;
|
|
|
|
+ ((struct qelem *) elem)->q_forw = next;
|
|
|
|
+ ((struct qelem *) elem)->q_back = (struct qelem *) prev;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|