Thread: Linked List remove node issue

  1. #1
    Registered User
    Join Date
    Apr 2008

    Unhappy Linked List remove node issue

    Hi Everyone,
    I am stuck at removing element from linked list. The error I get while compiling under linux is:
    *** glibc detected *** free(): invalid next size (fast): 0x0804a028 ***
    Error I get from windows is:
    Windows has triggered a breakpoint in test1.exe.

    This may be due to a corruption of the heap, and indicates a bug in test1.exe or any of the DLLs it has loaded.
    The structure and function that I use to delete are:
    typedef struct text *aText;
    struct line {
        int size;
        char *text;
        aText next;
        aText prev;
    void RemoveNode(aText node) {
    	if (node!=NULL) {
    When such an issue occurs? and what does it mean ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you have
    A <-> B <-> C
    and you remove B without first fixing A->next = C and C->prev = A, you end up with a broken list.

    Further special care at the ends of the lists is required.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 01:48 AM
  2. help me debug this linked list !
    By Dark Angel in forum C Programming
    Replies: 6
    Last Post: 04-18-2008, 02:10 PM
  3. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  4. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  5. Dynamic list of Objects in External File
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 12-18-2002, 02:05 PM