public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug manual/1506] New: Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE
@ 2005-10-20 16:14 dleppik at vocalabs dot com
  2005-10-20 16:19 ` [Bug manual/1506] " jakub at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dleppik at vocalabs dot com @ 2005-10-20 16:14 UTC (permalink / raw)
  To: glibc-bugs

The man page describing sys/queue.h include sample code which is written in a
way that suggests that the *_REMOVE macros free memory.  For example:

 while (head.lh_first != NULL)           /* Delete. */
             LIST_REMOVE(head.lh_first, entries);

As a general purpose example of how to clear a LIST, this is misleading. 
Especially for all the kids today whose primary language is Java, C#, or
Objective-C.  (Sadly, I've become one of those kids :-) )

FreeBSD's current man page is more verbose:

                                             /* TailQ Deletion. */
> >      while (!TAILQ_EMPTY(&head)) {
> >              n1 = TAILQ_FIRST(&head);
> >              TAILQ_REMOVE(&head, n1, entries);
> >              free(n1);
> >      }
> >                                              /* Faster TailQ Deletion. */
> >      n1 = TAILQ_FIRST(&head);
> >      while (n1 != NULL) {
> >              n2 = TAILQ_NEXT(n1, entries);
> >              free(n1);
> >              n1 = n2;
> >      }
> >      TAILQ_INIT(&head);

(Thanks to John Baldwin for pointing the FreeBSD version out to me.)

-- 
           Summary: Memory leak in sample code for LIST_, TAILQ_, and
                    CIRCLEQ_REMOVE
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: manual
        AssignedTo: roland at gnu dot org
        ReportedBy: dleppik at vocalabs dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=1506

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug manual/1506] Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE
  2005-10-20 16:14 [Bug manual/1506] New: Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE dleppik at vocalabs dot com
@ 2005-10-20 16:19 ` jakub at redhat dot com
  2005-10-20 16:43 ` dleppik at vocalabs dot com
  2005-10-23  1:03 ` roland at gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at redhat dot com @ 2005-10-20 16:19 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2005-10-20 16:19 -------


*** This bug has been marked as a duplicate of 1481 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://sourceware.org/bugzilla/show_bug.cgi?id=1506

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug manual/1506] Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE
  2005-10-20 16:14 [Bug manual/1506] New: Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE dleppik at vocalabs dot com
  2005-10-20 16:19 ` [Bug manual/1506] " jakub at redhat dot com
@ 2005-10-20 16:43 ` dleppik at vocalabs dot com
  2005-10-23  1:03 ` roland at gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: dleppik at vocalabs dot com @ 2005-10-20 16:43 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From dleppik at vocalabs dot com  2005-10-20 16:43 -------
Subject: Re:  Memory leak in sample code for LIST_, TAILQ_,
 and CIRCLEQ_REMOVE

Should I create a bug that there is no documentation for
libc/misc/sys/queue.h, or is there someone else who mantains that code?

David


jakub at redhat dot com wrote:
> ------- Additional Comments From jakub at redhat dot com  2005-10-20 16:19 -------
> 
> 
> *** This bug has been marked as a duplicate of 1481 ***
> 




-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=1506

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug manual/1506] Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE
  2005-10-20 16:14 [Bug manual/1506] New: Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE dleppik at vocalabs dot com
  2005-10-20 16:19 ` [Bug manual/1506] " jakub at redhat dot com
  2005-10-20 16:43 ` dleppik at vocalabs dot com
@ 2005-10-23  1:03 ` roland at gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: roland at gnu dot org @ 2005-10-23  1:03 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From roland at gnu dot org  2005-10-23 01:03 -------
You can file an enhancement bug on the manual that the header and its macros
should be documented.  But the most effective thing will be to contribute some
documentation to the manual.  This is far from the highest priority for
improving the libc manual, and there is nearly no volunteer time available for
working on the manual.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=1506

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-23  1:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-20 16:14 [Bug manual/1506] New: Memory leak in sample code for LIST_, TAILQ_, and CIRCLEQ_REMOVE dleppik at vocalabs dot com
2005-10-20 16:19 ` [Bug manual/1506] " jakub at redhat dot com
2005-10-20 16:43 ` dleppik at vocalabs dot com
2005-10-23  1:03 ` roland at gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).