* posix/glob.c (glob_in_dir): Add some comments and asserts to

explain why there are no leaks.
This commit is contained in:
Ulrich Drepper 2006-09-30 15:09:35 +00:00
parent 690c3947ed
commit f01e40699c
6 changed files with 27 additions and 2 deletions

View File

@ -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> 2006-09-29 Ulrich Drepper <drepper@redhat.com>
* libio/wmemstream.c: Include <wchar.h>. * libio/wmemstream.c: Include <wchar.h>.

View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <wchar.h>
static int static int

View File

@ -1,3 +1,5 @@
#include <wchar.h>
#define CHAR_T wchar_t #define CHAR_T wchar_t
#define W(o) L##o #define W(o) L##o
#define OPEN_MEMSTREAM open_wmemstream #define OPEN_MEMSTREAM open_wmemstream

View File

@ -1,3 +1,5 @@
#include <wchar.h>
#define CHAR_T wchar_t #define CHAR_T wchar_t
#define W(o) L##o #define W(o) L##o
#define OPEN_MEMSTREAM open_wmemstream #define OPEN_MEMSTREAM open_wmemstream

View File

@ -20,6 +20,7 @@
#include "strfile.h" #include "strfile.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <wchar.h>
struct _IO_FILE_wmemstream struct _IO_FILE_wmemstream

View File

@ -1287,8 +1287,15 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
for (size_t i = 0; i < cur; ++i) for (size_t i = 0; i < cur; ++i)
free (names->name[i]); free (names->name[i]);
names = names->next; 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) if (names == NULL)
{
assert (old == &init_names);
break; break;
}
cur = names->count; cur = names->count;
if (old == names_alloca) if (old == names_alloca)
names_alloca = names; 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++] new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
= names->name[i]; = names->name[i];
names = names->next; 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) if (names == NULL)
{
assert (old == &init_names);
break; break;
}
cur = names->count; cur = names->count;
if (old == names_alloca) if (old == names_alloca)
names_alloca = names; names_alloca = names;