+2006-09-30 Ulrich Drepper <drepper@redhat.com>
+
+ * posix/glob.c (glob_in_dir): Add some comments and asserts to
+ explain why there are no leaks.
+
2006-09-29 Ulrich Drepper <drepper@redhat.com>
* libio/wmemstream.c: Include <wchar.h>.
for (size_t i = 0; i < cur; ++i)
free (names->name[i]);
names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
if (names == NULL)
- break;
+ {
+ assert (old == &init_names);
+ break;
+ }
cur = names->count;
if (old == names_alloca)
names_alloca = names;
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
= names->name[i];
names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
if (names == NULL)
- break;
+ {
+ assert (old == &init_names);
+ break;
+ }
cur = names->count;
if (old == names_alloca)
names_alloca = names;