mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
[BZ #2766]
2006-06-14 Jakub Jelinek <jakub@redhat.com> [BZ #2766] * misc/insremque.c (insque): Handle prev == NULL. * misc/Makefile (tests): Add tst-insremque. * misc/tst-insremque.c: New test.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992, 1995, 1996, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -24,12 +24,20 @@
|
||||
void
|
||||
insque (void *elem, void *prev)
|
||||
{
|
||||
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;
|
||||
if (prev == NULL)
|
||||
{
|
||||
((struct qelem *) elem)->q_forw = NULL;
|
||||
((struct qelem *) elem)->q_back = NULL;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlink ELEM from the doubly-linked list that it is in. */
|
||||
|
Reference in New Issue
Block a user