diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-09-30 15:09:35 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-09-30 15:09:35 +0000 |
commit | f01e40699cc30cbaca756ecae6e08718d7530d20 (patch) | |
tree | 1d01936c3b0d192021c3cef15c58612e3ca15eea | |
parent | 690c3947edd0685817eb985e9cd58ecf043f2095 (diff) | |
download | glibc-f01e40699cc30cbaca756ecae6e08718d7530d20.tar.gz |
* posix/glob.c (glob_in_dir): Add some comments and asserts to
explain why there are no leaks.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libio/bug-wmemstream1.c | 1 | ||||
-rw-r--r-- | libio/tst-wmemstream1.c | 2 | ||||
-rw-r--r-- | libio/tst-wmemstream2.c | 2 | ||||
-rw-r--r-- | libio/wmemstream.c | 1 | ||||
-rw-r--r-- | posix/glob.c | 18 |
6 files changed, 27 insertions, 2 deletions
@@ -1,3 +1,8 @@ +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>. diff --git a/libio/bug-wmemstream1.c b/libio/bug-wmemstream1.c index 2190593c93..22d67f71e9 100644 --- a/libio/bug-wmemstream1.c +++ b/libio/bug-wmemstream1.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <string.h> +#include <wchar.h> static int diff --git a/libio/tst-wmemstream1.c b/libio/tst-wmemstream1.c index 0c59c1adcb..f8b308bc6c 100644 --- a/libio/tst-wmemstream1.c +++ b/libio/tst-wmemstream1.c @@ -1,3 +1,5 @@ +#include <wchar.h> + #define CHAR_T wchar_t #define W(o) L##o #define OPEN_MEMSTREAM open_wmemstream diff --git a/libio/tst-wmemstream2.c b/libio/tst-wmemstream2.c index f51a1db20c..e2442ebfac 100644 --- a/libio/tst-wmemstream2.c +++ b/libio/tst-wmemstream2.c @@ -1,3 +1,5 @@ +#include <wchar.h> + #define CHAR_T wchar_t #define W(o) L##o #define OPEN_MEMSTREAM open_wmemstream diff --git a/libio/wmemstream.c b/libio/wmemstream.c index 85ea64991a..577931888d 100644 --- a/libio/wmemstream.c +++ b/libio/wmemstream.c @@ -20,6 +20,7 @@ #include "strfile.h" #include <stdio.h> #include <stdlib.h> +#include <wchar.h> struct _IO_FILE_wmemstream diff --git a/posix/glob.c b/posix/glob.c index 630d54063a..0079a15a92 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -1287,8 +1287,15 @@ glob_in_dir (const char *pattern, const char *directory, int flags, 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; @@ -1306,8 +1313,15 @@ glob_in_dir (const char *pattern, const char *directory, int flags, 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; |