Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22077

Re: linked list

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Sat, 09 Jun 2012 15:01:23 -0500
Message-ID <4FD3AB92.4183@mindspring.com> (permalink)
Date Sat, 09 Jun 2012 16:01:22 -0400
From pete <pfiland@mindspring.com>
Reply-To pfiland@mindspring.com
Organization PF
X-Mailer Mozilla 3.04Gold (WinNT; I)
MIME-Version 1.0
Newsgroups comp.lang.c
Subject Re: linked list
References <bc9a4156-754e-4251-bfab-d75241dad420@googlegroups.com> <4FD32A2F.1A9E@mindspring.com> <4FD33350.63FA@mindspring.com> <15da424e-f82e-4580-ac2c-1fc8f7563c15@googlegroups.com>
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Lines 24
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 4.154.216.98
X-Trace sv3-ABFlatht92UBNOR171bkvvGBpATlfdSHu3VzievBT/4sOcNVjaFHpo73F5eKZyOiaZKGC6MD00KXRPF!pdBzNbwcuoxpsMnENBnGsRXnFVA99d5e4ry2UBHmi5dUx8zYd3F2XZ5jL27gMCBxi5pz81OE1eGG!yoVNDP/GDg==
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1622
X-Received-Bytes 1802
Xref csiph.com comp.lang.c:22077

Show key headers only | View raw


Zhang Yuan wrote:
> 
> On Saturday, June 9, 2012 7:28:16 PM UTC+8, pete wrote:
> > pete wrote:

> > void
> > stu_free(struct stu *head)
> > {
> >     struct stu *next;
> >
> >     while (head != NULL) {
> >         next = head -> next;
> >         free(head);
> >         head = next;
> >     }
> 
> Why not just free head?

Because just freeing head, 
would leave the rest of the nodes in the linked list,
inaccessible yet still allocated.

-- 
pete

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 21:02 -0700
  Re: linked list Kaz Kylheku <kaz@kylheku.com> - 2012-06-09 04:59 +0000
    Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 22:13 -0700
    Re: linked list Ian Collins <ian-news@hotmail.com> - 2012-06-09 17:47 +1200
      Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 22:59 -0700
        Re: linked list Ian Collins <ian-news@hotmail.com> - 2012-06-09 18:35 +1200
          Re: linked list Ike Naar <ike@sverige.freeshell.org> - 2012-06-09 06:53 +0000
            Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-09 00:53 -0700
    Re: linked list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-06-22 12:18 -0700
  Re: linked list Ike Naar <ike@sverige.freeshell.org> - 2012-06-09 05:34 +0000
    Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 22:51 -0700
      Re: linked list Ike Naar <ike@sverige.freeshell.org> - 2012-06-09 06:45 +0000
        Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 23:56 -0700
    Re: linked list Keith Thompson <kst-u@mib.org> - 2012-06-09 11:17 -0700
      Re: linked list Ike Naar <ike@iceland.freeshell.org> - 2012-06-09 22:02 +0000
  Re: linked list Ian Collins <ian-news@hotmail.com> - 2012-06-09 17:49 +1200
    Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 22:53 -0700
      Re: linked list Ian Collins <ian-news@hotmail.com> - 2012-06-09 18:36 +1200
      Re: linked list Keith Thompson <kst-u@mib.org> - 2012-06-09 11:20 -0700
  Re: linked list pete <pfiland@mindspring.com> - 2012-06-09 06:49 -0400
    Re: linked list pete <pfiland@mindspring.com> - 2012-06-09 07:28 -0400
      Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-09 07:57 -0700
        Re: linked list Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-09 19:16 +0100
        Re: linked list pete <pfiland@mindspring.com> - 2012-06-09 16:01 -0400
        Re: linked list pete <pfiland@mindspring.com> - 2012-06-09 16:50 -0400
          Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-09 18:21 -0700
            Re: linked list pete <pfiland@mindspring.com> - 2012-06-10 00:11 -0400
              Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-09 22:20 -0700
                Re: linked list pete <pfiland@mindspring.com> - 2012-06-10 08:31 -0400
            Re: linked list nick_keighley_nospam@hotmail.com - 2012-06-11 06:10 -0700
              Re: linked list Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-11 09:16 -0700
              Re: linked list Keith Thompson <kst-u@mib.org> - 2012-06-11 15:45 -0700
                Re: linked list Michael Press <rubrum@pacbell.net> - 2012-06-14 12:47 -0700

csiph-web